doubles011
New Member
- Joined
- Jul 21, 2015
- Messages
- 1
I am trying to write a macro that I will use to insert vlookups into a number of different workbooks. The problem I am having is that the lookup array is composed of numbers stored as text in the source material, while the lookup values are stored as "general" in the workbooks in which I am inserting the vlookups. I tried just changing the lookup array to general, but it eliminates leading 0s that i need to keep. I also tried changing the lookup values to text, but this required me to go through and double click each cell so that the number would actually be stored as text. I then tried writing some code that would insert a column, change the number format to text in the blank column and then copy the lookup values and paste values in the new text column -- but that did not work either (using code below). Does anyone have any suggestions about how i can get these lookup values to be text without going through and individually selecting them all? Thanks
Columns("E:E").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.NumberFormat = "@"
Columns("D:D").Copy
Columns("E:E").PasteSpecial Paste:=xlPasteValues
Columns("E:E").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.NumberFormat = "@"
Columns("D:D").Copy
Columns("E:E").PasteSpecial Paste:=xlPasteValues