I have three columns of data. Is there a way using vba to insert the information into a label on a userForm?
Here is the updated code I have:
Dim rowNum As Integer
Dim lastRow As Integer
lastRow = 373
For rowNum = 2 To lastRow
report = Sheet开发者_开发问答s("DATA2").Range("F" & rowNum).Text & _
" " & Sheets("DATA2").Range("G" & rowNum).Text & _
" " & Sheets("DATA2").Range("H" & rowNum).Text & vbCrLf
Next rowNum
End Sub
Try:
Dim rowNum as Integer 'loop counter
Dim lastRow as Integer
lastRow = 'some code to set the row number of the bottom row
For rowNum = 1 to lastRow
With ActiveWorksheet
myLabel.Text = myLabel.Text & .Range("A" & rowNum).Text & " " & .Range("B" & rowNum).Text & " " & .Range("C" & rowNum).Text & vbCrLf
End With
Next rowNum
EDIT
Updated to append each loop instead of over-writing
Assuming that your label can handle multiple lines, you could write a loop that iterates through each column of data and appends it to a String as a new line, and then set the text field of that label to the string you created.
精彩评论