Link to home
Start Free TrialLog in
Avatar of hgj1357
hgj1357

asked on

Excel " symbol in a text string

I am creating a VBA to open multiole CSV files and process the contents.

I am using excel to generate the VBA code then pasting it into excel's VBA

I'm running into problems with the " symbol

I need to be able to enter this text field:

Workbooks.OpenText Filename:="X:\Projects\Data\01.txt"

However, I'd like to be able to have a column of numbers: 1,2,3,4...etc  and use

="Workbooks.OpenText Filename:="X:\Projects\Data\" & format(A1,"00") & ".txt"

However, the " symbol in the string prevents this from working.

I can use @ instead of " 

="Workbooks.OpenText Filename:=@X:\Projects\Data\" & format(A1,"00") & ".txt@"

Then use a text editor to replace @ with " but I'd like a more elegant solution as this will be used to add ~ ½ million data points.
Avatar of NBVC
NBVC
Flag of Canada image

Maybe it should be?

="Workbooks.OpenText Filename:=""X:\Projects\Data\" & Format(A1, "00") & ".txt"""
If you want literal "s then you need to double them up, try

="Workbooks.OpenText Filename:=""X:\Projects\Data\" & format(A1,"00") & ".txt"""

regards, barry
Avatar of hgj1357
hgj1357

ASKER

Nope. Neither of these work.
ASKER CERTIFIED SOLUTION
Avatar of hgj1357
hgj1357

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sorry hgj1357 I'm only a part-timer with VBA!

Jeez NBVC, we need some proper VBA people in here.......

regards, barry
So true, barry!  It's funny how we both came up with the exact same suggestion!  Just shows where we stand with VBA.  ROFL!
Avatar of hgj1357

ASKER

I should have spent more time on it before posting.