VLOOKUP with VB

R

ram

Hi,

I have the current code and would like help with two queestions:

1) is it possible to return the value and not the formula
2) Is it possible to enter the formula in all the cells without using copy
down


'Copy EIF Numbers to NB sheet
Sheets("NB").Range("P3") = "EIF"
Sheets("NB").Range("O3").Copy
Sheets("NB").Range("P3").PasteSpecial Paste:=xlPasteFormats
Sheets("NB").Range("P4").FormulaR1C1 =
"=VLOOKUP(NB!RC[-15]&RC[-14],EIF!C[-15]:C[-9],7,FALSE)"
LastRow = Sheets("NB").Range("D" & Rows.Count).End(xlUp).Row
Sheets("NB").Range("P4").Copy _
Destination:=Sheets("NB").Range("P5:p" & (LastRow))
 
P

p45cal

ram;693995 said:
Hi,

I have the current code and would like help with two queestions:

1) is it possible to return the value and not the formula
2) Is it possible to enter the formula in all the cells without usin copy
down


'Copy EIF Numbers to NB sheet
Sheets("NB").Range("P3") = "EIF"
Sheets("NB").Range("O3").Copy
Sheets("NB").Range("P3").PasteSpecial Paste:=xlPasteFormats
Sheets("NB").Range("P4").FormulaR1C1 =
"=VLOOKUP(NB!RC[-15]&RC[-14],EIF!C[-15]:C[-9],7,FALSE)"
LastRow = Sheets("NB").Range("D" & Rows.Count).End(xlUp).Row
Sheets("NB").Range("P4").Copy _
Destination:=Sheets("NB").Range("P5:p" & (LastRow))





VBA Code:
--------------------


LastRow = Sheets("NB").Range("D" & Rows.Count).End(xlUp).Row
With Sheets("NB").Range("P4:p" & LastRow)
.FormulaR1C1 = "=VLOOKUP(NB!RC[-15]&RC[-14],EIF!C[-15]:C[-9],7,FALSE)"
.Value = .Value
End With
 
R

ram

Thank you just what I needed

p45cal said:
ram;693995 said:
Hi,

I have the current code and would like help with two queestions:

1) is it possible to return the value and not the formula
2) Is it possible to enter the formula in all the cells without using copy
down


'Copy EIF Numbers to NB sheet
Sheets("NB").Range("P3") = "EIF"
Sheets("NB").Range("O3").Copy
Sheets("NB").Range("P3").PasteSpecial Paste:=xlPasteFormats
Sheets("NB").Range("P4").FormulaR1C1 =
"=VLOOKUP(NB!RC[-15]&RC[-14],EIF!C[-15]:C[-9],7,FALSE)"
LastRow = Sheets("NB").Range("D" & Rows.Count).End(xlUp).Row
Sheets("NB").Range("P4").Copy _
Destination:=Sheets("NB").Range("P5:p" & (LastRow))

VBA Code:
LastRow = Sheets("NB").Range("D" & Rows.Count).End(xlUp).Row
With Sheets("NB").Range("P4:p" & LastRow)
.FormulaR1C1 = "=VLOOKUP(NB!RC[-15]&RC[-14],EIF!C[-15]:C[-9],7,FALSE)"
.Value = .Value
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top