Help with vba using VlookUp

Gregm66

Board Regular
Joined
Jan 23, 2016
Messages
170
Hi Everyone,

My Question today is about using vlookup in vba, or something of the like.
I have 2 worksheets one named "Members" the other named "Fees Paid". Currently i am using vlookup in cells that require it, what i would like to do is use vba to accomplish this task instead.

The "Members Sheet " is where all data is manually entered, The "Fees Paid Sheet" has 8 Columns "A" through to "H" column A uses vlookup, column B uses Data Validation List, Column's C,D & E all use vlookup, Once the user selects a name in column B then the rest of the columns return the matching Data for that name.

is there a way to have vba do this so that i can remove all formulas from column's A,C,D & E....? This must continue down the worksheet over time until the worksheet is full.

Thankyou all in advance...
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Try this

Put the following code in the event of the sheet "Fees paid"


Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.Count > 1 Then Exit Sub
  If Target.Value = "" Then Exit Sub
  Dim sh As Worksheet, f As Range
  If Not Intersect(Target, Range("B:B")) Is Nothing Then
    Set sh = Sheets("Members")
    Set f = sh.Range("[COLOR=#ff0000]A:A[/COLOR]").Find(Target.Value, , xlValues, xlWhole)
    If Not f Is Nothing Then
      '[COLOR=#0000ff]cell destination              cell origin[/COLOR]
      Cells(Target.Row, "A").Value = sh.Cells(f.Row, "B").Value
      Cells(Target.Row, "C").Value = sh.Cells(f.Row, "C").Value
      Cells(Target.Row, "D").Value = sh.Cells(f.Row, "D").Value
      Cells(Target.Row, "E").Value = sh.Cells(f.Row, "E").Value
      Cells(Target.Row, "F").Value = sh.Cells(f.Row, "F").Value
      Cells(Target.Row, "G").Value = sh.Cells(f.Row, "G").Value
      Cells(Target.Row, "H").Value = sh.Cells(f.Row, "H").Value
    Else
      MsgBox "Member does not exists"
    End If
  End If
End Sub

You did not mention in which column of the "members" sheet the search is performed, then change "A:A" to that column.


You must also adjust the destination columns and the origin column.


SHEET EVENT
Right click the tab of the sheet you want this to work (Fees paid), select view code and paste the code into the window that opens up.

Then, when you select a member on the "Fees paid" sheet, the macro automatically runs.


Let me know if you have any doubt.
 
Upvote 0
Are you saying when you enter "Alpha" in column A of Fees Paid sheet you want the script to look in sheet named Members Column A for "Alpha" and then copy the whole row from sheet Members to sheet Fees Paid?
 
Last edited:
Upvote 0
The columns in the Members sheet hold the members names ph numbers etc, if in column B on the fees paid sheet the user selects a members name, then columns A,C,D & E need to seach the members sheet and return the matching details for that particular member...
the vlookup in each cell that i am using to do this looks like see below..

Code:
=IFERROR(VLOOKUP(B2,Members,2,FALSE),"")
 
Upvote 0
Sorry the above code is in the fees paid sheet..
the code is in column "A" column "C" column "D" column "E"
 
Upvote 0
Thankyou DanteAmor

the code that you supplied works i just need to change it around alittle but it works fine...

Thankyou everyone for your help, my problem with this one has been solved...
 
Upvote 0
Thankyou DanteAmor

the code that you supplied works i just need to change it around alittle but it works fine...

Thankyou everyone for your help, my problem with this one has been solved...


I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,412
Messages
6,119,365
Members
448,888
Latest member
Arle8907

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