How to convert a cell to a number format for vlookup

fvisions

Board Regular
Joined
Jul 29, 2008
Messages
191
Office Version
  1. 365
Platform
  1. Windows
I have a large file with a vba code that does several things. One being a vlookup from a column. The vlookup results are #N/A due to the lookup value needing to be converted to a number. How do I update the code to go to column i and convert the full column to a number?

1604584536883.png

VBA Code:
 Dim LastRow As Long
    LastRow = Cells(Rows.Count, 2).End(xlUp).Row
    Range("K2").Select
    Application.CutCopyMode = False
    Application.CutCopyMode = False
    Range("K2:K" & LastRow).FormulaR1C1 = "=VLOOKUP(RC[-2],'Plant and Status List'!R3C5:R1071C8,4,FALSE)"
    Range("K2:K" & LastRow).Value = Range("K2:K" & LastRow).Value
    Range("K1").Select
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Try changing this line:
Rich (BB code):
    Range("K2:K" & LastRow).FormulaR1C1 = "=VLOOKUP(RC[-2],'Plant and Status List'!R3C5:R1071C8,4,FALSE)"
to this:
Rich (BB code):
    Range("K2:K" & LastRow).FormulaR1C1 = "=VLOOKUP(RC[-2]+0,'Plant and Status List'!R3C5:R1071C8,4,FALSE)"
 
Upvote 0
Add 'Helper' column to Convert the data (use =value(cell) )and then change your Vlookup formula to look at the Valued cell.. Or change your lookup table to String values, if you have preceding zeros this may be your best way to handle this. if you posted a fuller example it would be easier to 'see' what you're doing.
 
Upvote 0
Add 'Helper' column to Convert the data (use =value(cell) )and then change your Vlookup formula to look at the Valued cell.. Or change your lookup table to String values, if you have preceding zeros this may be your best way to handle this. if you posted a fuller example it would be easier to 'see' what you're doing.
I don't think there should be any need to go to these lengths.
You should be able to easily adapt the VLOOKUP formula like I have shown to address the issue.
If you have a number entered as text that you need to treat like a number, all you need to do is to coerce it to a number by performing some simple mathematical computation on it, like adding zero or multiplying by 1. And you can do that right in the VLOOKUP formula, like I have shown above.
 
Upvote 0
I don't think there should be any need to go to these lengths.
You should be able to easily adapt the VLOOKUP formula like I have shown to address the issue.
If you have a number entered as text that you need to treat like a number, all you need to do is to coerce it to a number by performing some simple mathematical computation on it, like adding zero or multiplying by 1. And you can do that right in the VLOOKUP formula, like I have shown above.
IT IS RUNNING PERFECTLY NOW...YOU ARE THE BEST!!! I have a meeting today with my boss to show him and I was stressed to the max. Thank you, Thank you, Thank you
 
Upvote 0
IT IS RUNNING PERFECTLY NOW...YOU ARE THE BEST!!! I have a meeting today with my boss to show him and I was stressed to the max. Thank you, Thank you, Thank you
You are welcome.
Glad we were able to help you out!
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,688
Members
448,978
Latest member
rrauni

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