Autofill Macro

olly_w

Board Regular
Joined
Jul 2, 2003
Messages
189
Hi guys

I've got a formula I need to run using a macro, and need it to run from Row 3 of the worksheet to the last used row.

The formula is =vlookup, J3, $BI:$BJ, 2, FALSE) - with the J3 reference incrementing (i.e. J4, J5 etc).

Any ideas on how best to run this using VBA? Any help greatly appreciated.

Regards

Olly
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
You didn't say what column you wanted the formula in, I choose K, adjust as needed.
Code:
Range("K3:K" & ActiveSheet.UsedRange.Rows.Count).Formula = _
        "=VLOOKUP(J3,$BI:$BJ, 2, FALSE)"
 
Upvote 0
Guys this is great, thanks.

Is there a way to nest something into the VBA code so that, once the lookup has been performed, that "paste special" is carried out on these cells so that the formula is removed and just the values left?

Cheers

Olly
 
Upvote 0
Guys this is great, thanks.

Is there a way to nest something into the VBA code so that, once the lookup has been performed, that "paste special" is carried out on these cells so that the formula is removed and just the values left?

Cheers

Olly
 
Upvote 0
Just add this line after the formula line:
Code:
Range("K3:K" & ActiveSheet.UsedRange.Rows.Count).Value = _ 
Range("K3:K" & ActiveSheet.UsedRange.Rows.Count).Value
 
Upvote 0

Forum statistics

Threads
1,215,043
Messages
6,122,812
Members
449,095
Latest member
m_smith_solihull

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