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

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Datsmart

Well-known Member
Joined
Jun 19, 2003
Messages
7,985
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

olly_w

Board Regular
Joined
Jul 2, 2003
Messages
189
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

olly_w

Board Regular
Joined
Jul 2, 2003
Messages
189
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

Datsmart

Well-known Member
Joined
Jun 19, 2003
Messages
7,985
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,191,174
Messages
5,985,106
Members
439,940
Latest member
Kyrad42

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
Top