• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Carriage return VLOOKUP issue

chirayu

Well-Known Member
Hi guys,

This is an odd one & I can't seem to get past it. Problem below:

- I have 2 sheets e.g. Sheet1 & Sheet2
- Trying to do a VLOOKUP in Sheet2 (Main table is on Sheet1)
- VBA gives an error because Sheet1 name has a carriage return in it
- Tried storing sheet name as a String variable but its not working
 
yeah I ended up doing below
Code:
Sht = ActiveSheet.Name
Sht = Replace(Sht, chr(10), "")
ActiveSheet.Name = Sht
 

So I was not a CR but a LF (line feed) !
A must see in VBA inner help : VB constants like vbCr and vbLf …

Activesheet.Name = Replace(Activesheet.Name, vbLf, "")
 
Back
Top