Excel Macro - Copying Vlookup formula down to last cell

wardie

New Member
Joined
Aug 28, 2014
Messages
3
Currently I am trying to automate a report build that can have a different number of rows each time it is run (weekly)

Column A has the list of devices found.

Columns B & C have data but not consistent (lots of blanks).

Columns D - T are vlookups that I would manually drag down to the last cell of Column A each time.

I'm trying to macro the copying of the vlookup formula to the last row but am stuck trying to find the code to do my task.

My current bad code for this copies down to the last row of the spreadsheet.

Sheets("ServerList").Activate
Range("D2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],Working_FACTS!C[-3]:C[-1],3,0)"
Range("D2").Select
Selection.Copy
* Range(ActiveCell, ActiveCell.End(xlDown)).Select
ActiveSheet.Paste
Range("D2").Select
* Range(ActiveCell, ActiveCell.End(xlDown)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

The lines with the * are the ones I need to fix. I need to capture the last cell # in Column A and transpose it to my Range.Select

Anybody with greater smarts than me like to suggest the easy fix??

Many Thanks

Wardie
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Try

Code:
Dim LR As Long
Sheets("ServerList").Activate
LR = Range("A" & Rows.Count).End(xlUp).Row
Range("D2").FormulaR1C1 = "=VLOOKUP(RC[-1],Working_FACTS!C[-3]:C[-1],3,0)"
Range("D2").AutoFill Destination:=Range("D2:D" & LR)
 
Upvote 0
Thank you VoG, that has solved my problem.

I knew it would be easy but had hit a mental road block
 
Upvote 0

Forum statistics

Threads
1,214,946
Messages
6,122,401
Members
449,081
Latest member
JAMES KECULAH

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