ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Assign range to userform labels and textboxes (https://www.excelbanter.com/excel-programming/447437-assign-range-userform-labels-textboxes.html)

danmack

Assign range to userform labels and textboxes
 
Hi all,

I'm putting together a Userform which is to be used to amend existing data in an excel worksheet. I've already put together a userform to load the data-no problems...however i'm struggling with my limited knowledge to work out this next phase.

The following code selects all the columns in the first row and populates the combo box with a list of part numbers from column A (so row to amend can be selected) which is fine. The rest of the code selects all the headings in Row 1 (for transfer into the caption property of my Userform Labels) when i only want the first 13 (range A1:13)-I can't work out the syntax needed to do this.

Private Sub UserForm_Activate()
With Data.Cells(1).CurrentRegion
Cbo_Partno.List = .Offset(1).Value
sq = .Rows(1)
End With

For j = 1 To UBound(sq, 2)
Me("Label" & j).Caption = sq(1, j)
Next

End Sub

Hopefully you guys can help with this and i'll learn something new (again!!)

Thanks


All times are GMT +1. The time now is 04:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com