Copied vlookup vba to a new vba setup and it wont work.

fvisions

Board Regular
Joined
Jul 29, 2008
Messages
191
Office Version
  1. 365
Platform
  1. Windows
I have a vlookup code that is coping the vlookup to the last row for a worksheet. I have a second worksheet that I am setting up and this step is exactly the same so I copied and pasted it to my VBA code but the vlookup is stopping at the H2 & I2 cells and not copying the vlookup to the end of the data. I have been hours looking at this...What am I missing?

VBA Code:
Dim LastRow As Long
   LastRow = Cells(Rows.Count, 2).End(xlUp).Row
    Range("H2").Select
    Application.CutCopyMode = False
    Application.CutCopyMode = False
    Range("h2:h" & LastRow).FormulaR1C1 = _
        "=VLOOKUP(RC[-7],'Exhibit Vlookup Table'!R4C3:R65C14,9,FALSE)"
    Range("h2:h" & LastRow).Value = Range("h2:h" & LastRow).Value
    Range("I2").Select
    Application.CutCopyMode = False
    Application.CutCopyMode = False
    Range("i2:i" & LastRow).FormulaR1C1 = _
        "=VLOOKUP(RC[-8],'Exhibit Vlookup Table'!R4C3:R65C14,12,FALSE)"
    Range("i2:i" & LastRow).Value = Range("i2:i" & LastRow).Value
Columns("A:J").Select
    Columns("A:J").EntireColumn.AutoFit
    Range("A1").Select
 

Attachments

  • 1604690443937.png
    1604690443937.png
    6.2 KB · Views: 3

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Do you have any data in col B?
 
Upvote 0
yes, below is a same of the full worksheet.
Contract AccountBusiness PartnerPoleRoad CodeRoad NameOperandRemoveInstallLED CostElectricity +/-
number
TWN OF GREAT 20401BENNETTS COVE ROADMLHPCS070SL HPS70W CUTOFF26 Watt LED
9.1​
number
TWN OF GREAT20415COTTAGE ROADMLHPCS070SL HPS70W CUTOFF
number
TWN OF GREAT113481SOUTH ROADMLHPCS070SL HPS70W CUTOFF
number
TWN OF GREAT4412CENTRAL AVENUEMLHPCS070SL HPS70W CUTOFF
number
TWN OF GREAT2.1480SCHOOL HOUSE ROADMLHPCS070SL HPS70W CUTOFF
number
TWN OF GREAT18460NORTH ROADMLHPCS070SL HPS70W CUTOFF
number
TWN OF GREAT3483STONE WHARF ROADMLHPCS070SL HPS70W CUTOFF
 
Upvote 0
In that case there should not be a problem, do you have any code after that?
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,897
Members
449,097
Latest member
dbomb1414

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