Solved

Excel " symbol in a text string

Posted on 2013-01-14
7
540 Views
Last Modified: 2013-01-19
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.
0
Comment
Question by:hgj1357
  • 3
  • 2
  • 2
7 Comments
 
LVL 23

Expert Comment

by:NBVC
ID: 38775906
Maybe it should be?

="Workbooks.OpenText Filename:=""X:\Projects\Data\" & Format(A1, "00") & ".txt"""
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 38775914
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
0
 
LVL 2

Author Comment

by:hgj1357
ID: 38775933
Nope. Neither of these work.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Accepted Solution

by:
hgj1357 earned 0 total points
ID: 38775960
It's quad. this does it:

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

Also, I was using Access 'format' when in excel it is 'text'
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 38776510
sorry hgj1357 I'm only a part-timer with VBA!

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

regards, barry
0
 
LVL 23

Expert Comment

by:NBVC
ID: 38778053
So true, barry!  It's funny how we both came up with the exact same suggestion!  Just shows where we stand with VBA.  ROFL!
0
 
LVL 2

Author Closing Comment

by:hgj1357
ID: 38796091
I should have spent more time on it before posting.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now