Código: Selecionar todos
Sub GuardarLitros()
Dim Ctrl As Control
Dim c As Integer, x As Integer
Dim strText As String
'Determina a coluna a ser utilizada
c = WorksheetFunction.Match(Me.ComboBoxMES.List(ComboBoxMES.ListIndex, 2), Sheets("GASOLEO").Range("A1:M1"), 0)
'Loop pelos controles do formulario
For Each Ctrl In UserForm_KmFimMes.Controls
'considerando textbox 801 a 807
For x = 1 To 7
If x <= 9 Then
strText = "TextBox80"
Else
strText = "TextBox8"
End If
If Ctrl.Name = strText & x Then
If Ctrl <> "" Then Sheets("GASOLEO").Cells(x + 2, c) = Ctrl.Value
End If
Next
Next
End Sub


