Excel Userform question (passing values and lookup)

pangster

Board Regular
Joined
Jun 15, 2005
Messages
160
Hi,

I'm looking for some guidance.. I've got the following setup:

(1) A userform which acts as a search interface
(2) A useform which 'should' show the individual record details selected in (1)

The source data is in a table and I can successfully pass the correct table row number to the second userform.. **BUT** I'm not sure how to use this value to lookup the data for the rest of the fields in the corresponding row to populate the userform?!

The VBA for the second userform is shown below:

<code>
Private Sub UserForm_Activate()

With Me
.txtRow.Value = Me.Tag
.txtArea.Value = Application.VLookup(Me.Tag, Sheets("SHEET1").Range("A6:AS4336"), 3, False)

End With
End Sub
</code>

I doesn't seem to like the 'Me.Tag' expression... can anyone offer any ideas or suggestions?? - I've been searching for a bit and can't really find a suitable answer.. thanks for any help or advice offered! :)
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
I dont know what doesnt seem to like means but Me.Tag should produce the tag of the initialised userform.
 
Upvote 0
EDIT: I was being stupid... (not surprising if you knew me) - I hadn't had my morning coffee...

there was a type mismatch!! - and figured it was easier to pass the Tag value to another object - so working code now looks like this :

<code>
Private Sub UserForm_Activate()

With Me
.txtRow.Value = Me.Tag
.TextBox1.Value = .txtRow.Value 'stores the Row number for the below lookups
.txtArea.Value = Application.VLookup(CLng(TextBox1.Value), Sheets("SHEET1").Range("A6:AS4336"), 3, False)
End With
End Sub
</code>
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,208
Members
448,554
Latest member
Gleisner2

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