autorun macro with vlookup function

STEEL010

Board Regular
Joined
Dec 29, 2017
Messages
76
Hi There,

I got a little held up on my work to autorun an vlookup function in vba.
I want to lookup a value that I created and auto populate in a cell
this is the code but it will not work, please help!

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(0, 0) = "$B$5" Then
Call lookup
End If
End Sub

Sub lookup()
On Error Resume Next
Range("B6").Value = "=VLookup(B5,pt_NL, 7, 0)"
Range("B6") = Range("B6")
End Sub

Greetings Steel010
 
Re: autorun macro with vlooup funtion

Because I do not want that the users see the code when they are editing the cell for a reason
 
Upvote 0

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Re: autorun macro with vlooup funtion

If this is an ActiveX-type combobox, put this in the worksheet's code module. Change the name of Combobox1 to the name of your combobox.

Code:
[color=darkblue]Private[/color] [color=darkblue]Sub[/color] [B]ComboBox1[/B]_Change()
    [color=darkblue]If[/color] Range("B5").Value <> "" [color=darkblue]Then[/color]
        Range("B6").Value = Evaluate("=VLookup(B5,pt_NL, 7, 0)")
    [color=darkblue]Else[/color]
        Range("B6").ClearContents
    [color=darkblue]End[/color] [color=darkblue]If[/color]
End [color=darkblue]Sub[/color]
 
Upvote 0
Re: autorun macro with vlooup funtion

YES!!!!:beerchug: it works, thank a lot. you helped me so much. thank you also for your patience.

have a good night

greeting

Steel010
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,197
Members
453,022
Latest member
RobertV1609

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