Automatically display informaton found in sheet1 like a Vlookup but in VBA

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,259
Office Version
  1. 2010
Platform
  1. Windows
[h=2]Hi I have the Vlookup code below which i used in a 'Northants' sheet in Excel where i entered data in J16 then in the others cells it automatically inputted the data found in sheet1.

Now i have made a userform7 where i want it to do the same thing, but i want to change cell J16 to a 'TextBox1' (where i enter my data) instead of using cells and vlookup. I want to put this into a userform instead,
so in textbox1 i will enter the data to search it will automatically find the details in sheet1 then in textbox3 and textbox4 it will display automatically the results.
can you help please, i am new to this still and i do apprecaite all the help i have had previously :)
[/h]
Code:
=VLOOKUP(Northants!$J$16, Sheet1!$A:$AA,26,FALSE))
[h=2]
[/h]
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Something like
Code:
Private Sub TextBox1_AfterUpdate()
   Dim Fnd As Range
   
   Set Fnd = Sheets("Sheet1").Range("A:A").Find(TextBox1.Value, , , xlWhole, , , False, , False)
   If Not Fnd Is Nothing Then
      TextBox3.Value = Fnd.Offset(, 25).Value
   End If
   
End Sub
 
Upvote 0
This works great thank you very much :), how can i add other textbox's to autofill for example textbox4, offset 3, for example or textbox5, offset 7? can you help on that please, thank you again this is great :)
 
Upvote 0
Simply copy the line where it sets the textbox3 value & change the name of the textbox & the offset accordingly
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,331
Members
452,636
Latest member
laura12345

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