Excel userform won't properly populate on initialize

UpnDown

New Member
Joined
Aug 3, 2014
Messages
5
I want my userform to initially populate with the data from the row's active cell on the same sheet. I'm using a command button to open the userform and I have a scrollbar on the userform to change between the records (spreadsheet rows) on the form.
I've tried several things but I can't get the form to populate with the data from the active cell when the userform opens. It will populate properly when I change the records with the scrollbar but always initially opens with blanks instead of the desired data from the row of the active cell.
Here is one of my latest attempts:
Code:
<code>Private Sub EmpUserForm_Initialize()
Dim eRow As Long
  If ActiveCell.Row > 3 And ActiveCell.Row < 104 Then
     eRow = ActiveCell.Row
 Else eRow = 4
 End If
  ScrollBar1.Max = WorksheetFunction.CountA(Range("eSS"))  ActiveSheet.ScrollBars("ScrollBar1").Value = eRow
  ...more code</code>
The scrollbar is not taking the value of eRow nor setting the maximum value.
I don't see any event for scrollbar that might enable this and I'm not sure how to pass the desired value properly.
Actually I'm not sure the event is being seen since I changed the name of the userform to EmpUserForm and I get errors if I try to change it back to simply UserForm.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
I had previously attempted to change the userform name when I tested using the correct call of Private Sub UserForm_Initialize() and that must have been the issue throwing the errors. I apparently fixed one hole and simultaneously created another by doing that. It works fine now by leaving the userform name as it is and using the correct call Private Sub UserForm_Initialize().
 
Upvote 0

Forum statistics

Threads
1,216,073
Messages
6,128,637
Members
449,461
Latest member
kokoanutt

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