Populating Text Boxes When Userform is Opened

nasa09

New Member
Joined
Oct 3, 2013
Messages
43
I've got a workbook with two worksheets titled "Input" and "Data," and a for titled frmFeeWaiver. When the form is opened, I'd like to populate the text boxes within that form using data from the current row on the the two worksheets.

I tried the following code, but nothing happens when the form is opened. Would somebody mind taking a look and telling me what I've done wrong?

(FYI, the two worksheets have corresponding data, but the row number on the "Data" sheet is different than the row number on "Input," hence the separate row number variables.)

Code:
Private Sub frmFeeWaiver_Activate()

Dim inputRow As Integer
Dim dataRow As Integer

inputRow = ActiveCell.Row
dataRow = inputRow - 5

txtReconPaid.Value = Sheets("Input").Range("L" & inputRow).Value
txtReconWaived.Value = Sheets("Data").Range("AB" & dataRow).Value
txtReconIn.Value = Sheets("Data").Range("AC" & dataRow).Value
txtStmtPaid.Value = Sheets("Input").Range("M" & inputRow).Value
txtStmtWaived.Value = Sheets("Data").Range("AE" & dataRow).Value
txtStmtIn.Value = Sheets("Data").Range("AF" & dataRow).Value
txtFaxPaid.Value = Sheets("Input").Range("N" & inputRow).Value
txtFaxWaived.Value = Sheets("Data").Range("AH" & dataRow).Value
txtFaxIn.Value = Sheets("Data").Range("AI" & dataRow).Value
txtUpdatePaid.Value = Sheets("Input").Range("O" & inputRow).Value
txtUpdateWaived.Value = Sheets("Data").Range("AK" & dataRow).Value
txtUpdateIn.Value = Sheets("Data").Range("AL" & dataRow).Value
txtAssnPaid.Value = Sheets("Input").Range("P" & inputRow).Value
txtAssnWaived.Value = Sheets("Data").Range("AN" & dataRow).Value
txtAssnIn.Value = Sheets("Data").Range("AO" & dataRow).Value
 

End Sub

Any help that you can provide would be greatly appreciated!!!
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Apparently it should! That fixed the problem. Thank you very much.

I thought that the Sub name should reference the actual form name, but apparently not.

Since the Sub doesn't refer specifically to the form in question, what prevents the same Sub from running when a different, unrelated form is opened?
 
Upvote 0
Each UserForm gets its own code module. And since the scope of sub is Private, it cannot be accessed from any other module.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,246
Members
449,075
Latest member
staticfluids

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