I'm working my way though the various ways to use IF function and now I'm a little stuck with loops.
I know how to just loop if I have to put it in to cells, but I don't know how to loop it when there is a IF and when I have to take the value from a combobox.
This is the code without loop
cR = ComboBox2.Value
If IsNull(cR) = False Then
tsheet.Range("B1").Value = cR
End If
cR = ""
cR = ComboBox3.Value
If IsNull(cR) = False Then
tsheet.Range("B2").Value = cR
End If
cR = ""
cR = ComboBox4.Value
If IsNull(cR) = False Then
tsheet.Range("B3").Value = cR
End If
So I can imagine the loop would look something like:
For i = 2 To 4
For k = 1 To 3
If Not ComboBox(i).Value = vbNullString
Range("B", k).Value = ComboBox(i).Value
next
End Sub
Ifisn't a function. Also, thecR = ""in the original code is pointless. You don't have to reset a variable before reusing it.