I'm pretty new to VBA still and was looking into For Loop to acomplish the following: Within the user form there are 3 text boxes. The first is the desired text to be sent to the work sheet. The second determines how many times Box 1 is repeated. The third determines how many times the value of Box 1 is increased by +1. Can someone help shed a light on this? This is what I have so far:
Private Sub PopulateVZC_Click()
Dim iRow As Long
iRow = Sheets("Log").Range("A5000").End(xlUp).Row + 1
Set lg = Sheets("Log")
lg.Select
With ThisWorkbook.Sheets("Log")
lg.Range("A" & iRow) = Me.VZC
lg.Range("B" & iRow) = Me.QTY
lg.Range("C" & iRow) = Me.BundleCount
End With
Unload Me
End Sub
Private Sub UserForm_Click()
Public Function RangeToArray(rng As Range) As Variant
Dim i As Long, r As Range
ReDim VZC(1 To rng.Count)
i = 1
For Each r In rng
VZC(i) = r.BundleCount
i = i + 1
Next r
RangeToArray = VZC
End Function
End Sub
Private Sub PopulateVZC_Click()
Dim iRow As Long
iRow = Sheets("Log").Range("A5000").End(xlUp).Row + 1
Set lg = Sheets("Log")
lg.Select
With ThisWorkbook.Sheets("Log")
lg.Range("A" & iRow) = Me.VZC
lg.Range("B" & iRow) = Me.QTY
lg.Range("C" & iRow) = Me.BundleCount
End With
Unload Me
End Sub
Private Sub UserForm_Click()
Public Function RangeToArray(rng As Range) As Variant
Dim i As Long, r As Range
ReDim VZC(1 To rng.Count)
i = 1
For Each r In rng
VZC(i) = r.BundleCount
i = i + 1
Next r
RangeToArray = VZC
End Function
End Sub