VBA multipage caption value from cell

wisemank

Board Regular
Joined
Jun 21, 2010
Messages
129
Hi there,

I have userform1 with a multipage on it. I need the captions for the multipage form to be populated from specific cell values. My issue is I need the range from A7 to A15 only, but I get way more than I need with this code found earlier... Any suggestions?


Private Sub UserForm_Initialize()


Dim pagecount As Long
Dim n As Long

pagecount = Sheets("Part Spec.").Range("a" & Rows.count).End(xlUp).Row - 5
n = 0

With MultiPage1
Do
If n >= .Pages.count Then .Pages.Add
.Pages(n).Caption = Sheets("Part Spec.").Range("a" & n + 6).Value
n = n + 1
Loop Until n = pagecount
End With
End Sub
 
need the range from A7 to A15 only
Try this:
Code:
Private Sub UserForm_Initialize()
    
    Dim pageCount As Long
    Dim n As Long
    
    pageCount = Sheets("Part Spec.").Range("A" & Rows.Count).End(xlUp).Row - 6
    n = 0
    
    With MultiPage1
        For n = 0 To pageCount - 1
            If n >= .Pages.Count Then .Pages.Add
            .Pages(n).Caption = Sheets("Part Spec.").Range("A" & n + 7).Value
        Next
    End With
    
End Sub
Please use CODE tags - the # icon in the message editor.
 
Upvote 0

Forum statistics

Threads
1,226,812
Messages
6,193,116
Members
453,777
Latest member
Miceal Powell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top