Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 208
Default vlookup and using single quote

I'm trying to code this piece:

..Range("Z" & NewRow2 & ":Z" & NewRow2).Formula = _
"=IF(ISNA(VLOOKUP($A6,INDIRECT("
'["&Y2&"]By_Rep_by_Filter'!$F$1:$P$5000"),11,FALSE)),""""," & _

"VLOOKUP($A6,INDIRECT("'["&Y2&"]By_Rep_by_Filter'!$F$1:$P$5000"),11,FALSE))"

But the single quote (') in the INDIRECT("' is causing everything after that
to be treated like a comment. How do I get the code to treat it just like a
regular character and not a comment?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default vlookup and using single quote

It's not the apostrophe, it's the incorrect number of double quotes:

.Range("Z" & NewRow2 & ":Z" & NewRow2).Formula = _
"=IF(ISNA(VLOOKUP($A6,INDIRECT(""'[""&Y2&""]By_Rep_by_Filter'" _
& "!$F$1:$P$5000""),11,FALSE)),""""," _
& "VLOOKUP($A6,INDIRECT(""'[""&Y2&""]By_Rep_by_Filter'" _
& "!$F$1:$P$5000""),11,FALSE))"

Remember to double up all of the double quotes.

And remember that if you're going to use =indirect(), then the sending workbook
needs to be open--otherwise, you'll see a #REF! error.

Bishop wrote:

I'm trying to code this piece:

.Range("Z" & NewRow2 & ":Z" & NewRow2).Formula = _
"=IF(ISNA(VLOOKUP($A6,INDIRECT("
'["&Y2&"]By_Rep_by_Filter'!$F$1:$P$5000"),11,FALSE)),""""," & _

"VLOOKUP($A6,INDIRECT("'["&Y2&"]By_Rep_by_Filter'!$F$1:$P$5000"),11,FALSE))"

But the single quote (') in the INDIRECT("' is causing everything after that
to be treated like a comment. How do I get the code to treat it just like a
regular character and not a comment?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9,101
Default vlookup and using single quote

It looks like you copied the statement from a posting. You have to put the
data instruction in one line of do this. I remove some of your double quotes
because they were in the wrong locations.

..Range("Z" & NewRow2 & ":Z" & NewRow2).Formula = _
"=IF(ISNA(VLOOKUP($A6,INDIRECT(" & _
"'["&Y2&"]By_Rep_by_Filter'!$F$1:$P$5000),11,FALSE)),""""," & _
"VLOOKUP($A6,INDIRECT('["&Y2&"]By_Rep_by_Filter'!$F$1:$P$5000),11,FALSE))"


"Bishop" wrote:

I'm trying to code this piece:

.Range("Z" & NewRow2 & ":Z" & NewRow2).Formula = _
"=IF(ISNA(VLOOKUP($A6,INDIRECT("
'["&Y2&"]By_Rep_by_Filter'!$F$1:$P$5000"),11,FALSE)),""""," & _

"VLOOKUP($A6,INDIRECT("'["&Y2&"]By_Rep_by_Filter'!$F$1:$P$5000"),11,FALSE))"

But the single quote (') in the INDIRECT("' is causing everything after that
to be treated like a comment. How do I get the code to treat it just like a
regular character and not a comment?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Single Quote use in cell reference Eric Excel Worksheet Functions 1 May 7th 08 05:19 PM
How do I display a single quote in a cell? Brotha B Excel Discussion (Misc queries) 1 August 17th 07 02:09 AM
Annoying single quote with ever new workbook oldtimer Excel Discussion (Misc queries) 5 February 25th 07 09:05 PM
using a single quote ' in SEARCH function ExTexan Excel Worksheet Functions 2 December 30th 06 01:11 PM
Remove single quote Avadivelan TCS Excel Worksheet Functions 4 October 5th 06 03:48 PM


All times are GMT +1. The time now is 10:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"