vlookup issue

lotsasmiles

New Member
Joined
Aug 13, 2007
Messages
5
I'm not sure if my post actually went thru, so I'm posting again. When trying to assign a cell value to a vlookup formula, it keeps adding (')s around part of my variable. I keep track of the worksheet I want to connect to (within the same workbook), and it's formatted like Month Year (ie: September 2007). So when I use the vba code of:
Code:
workingCell.Offset(1, 0).Value = "=IF(ISERROR(VLOOKUP(B9," & MonthName(month(targStName)) & " " & Year(targStName) & "!$B$9:$L$23,11,0)),"""",VLOOKUP(B9," & targStName & "!$B$9:$L$23,11,0))"
(trying two different ways), it appears in the cell as:
=IF(ISERROR(VLOOKUP(B9,October '2007'!$B$9:$L$23,11,0)),"",VLOOKUP(B9,October '2007'!$B$9:$L$23,11,0))
Notice the (')s around the year. How do I get rid of that as it's screwing things up? Any suggestions would be appreciated. Thanks!
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
You have a space in the worksheet name. Excel "helpfully" is trying to figure out what you want.

You need to put your own apostrophe "'" in the right place at the beginnig and end so it looks like
='[Book1]October 2007'!$A$1
eg
Code:
' not code really, but hopefully shows the characters better
"'" &"[Book1]October 2007" &"'!"
... etc

Personally I would use extra columns to calculate the strings and use reference to those in the VLOOKUP() - or more likely - use Find instead.
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,198
Members
449,072
Latest member
DW Draft

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