Vlookup till empty

Ildestino

New Member
Joined
Jun 23, 2014
Messages
15
Dear VBA Gurus,

I am dealing with several VLookups in my Report. I would like to set a VLookup from one worksheet to another. Currently, I am using this macro

Code:
Sub Vlookup_TestName()'
' VLOOKUPS
'


'
    Sheets("MRT Scor").Select
    ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],Auxiliaries!C[10]:C[11],2,FALSE)"
    Selection.AutoFill Destination:=Range("B2:B47916")
    Range("B2:B47916").Select
    Calculate
    Columns("B:B").Select
    Selection.Copy
    Range("B1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False


End Sub

It does work, but I am afraid, i would deal with more than 47916 rows per report. I would like to set up a Vlookup that should look up till the row is empty and paste the answer to the designated column.

I would be really happy and thankful for any hints or ideas.

Kind regards

Ildestino
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Code:
Sub Vlookup_TestName()'
' VLOOKUPS
'
Dim lr as Long
lr = Sheets("MRT Scor").Range("B" & Rows.Count).End(xlUp).Row
'
    Sheets("MRT Scor").Select
    ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],Auxiliaries!C[10]:C[11],2,FALSE)"
    Selection.AutoFill Destination:=Range("B2:B"& lr)
    Range("B2:B" & lr).Select
    Calculate
    Columns("B:B").Select
    Selection.Copy
    Range("B1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False


End Sub
 
Last edited:
Upvote 0
Code:
Sub Vlookup_TestName()'
' VLOOKUPS
'
Dim lr as Long
lr = Sheets("MRT Scor").Range("B" & Rows.Count).End(xlUp).Row
'
    Sheets("MRT Scor").Select
    ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],Auxiliaries!C[10]:C[11],2,FALSE)"
    Selection.AutoFill Destination:=Range("B2:B"& lr)
    Range("B2:B" & lr).Select
    Calculate
    Columns("B:B").Select
    Selection.Copy
    Range("B1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False


End Sub

Hey Barry,

thanks for your input. I was running your code and I got this error here:

Selection.AutoFill Destination:=Range("B2:B" & lr)

Run Time Error 1004

Autofill method of Range class failed

Any ideas?

Thank you very much for your input.

BR

Ildestino
 
Upvote 0
Code:
Sub Vlookup_TestName()'
' VLOOKUPS
'
Dim lr as Long
lr = Sheets("MRT Scor").Range("B" & Rows.Count).End(xlUp).Row
'
    Sheets("MRT Scor").Select
   Range("B2:B" & lr).FormulaR1C1 = "=VLOOKUP(RC[-1],Auxiliaries!C[10]:C[11],2,FALSE)"
    
    Range("B2:B" & lr).Select
    Calculate
    Columns("B:B").Select
    Selection.Copy
    Range("B1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False


End Sub
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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