Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default How to read a string in excel and include the single quote

I have the following value in a cell:
'TEST14','TEST15','TEST16'

When printing this value to a TXT file, I get:
TEST14','TEST15','TEST16'

How do I get to include the single quote that occurs in the beginning
of the string to be included in the output? Please help.

My code:

Sub Testme
Sheets("sheet01").Activate
gOutfile = "c:/test.txt"
Open gOutfile For Output As #1
For r = 1 To 30
xData = Cells(r, 1).Value
Print #1, xData
Next r
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default How to read a string in excel and include the single quote

Ricky,

It works fine for me but I do have 1 comment, you must close the file

Sub Testme()
Sheets("sheet01").Activate
gOutfile = "c:/test.txt"
Open gOutfile For Output As #1
For r = 1 To 30
xData = Cells(r, 1).Value
Print #1, xData
Next r
Close #1
End Sub

Mike

"Ricky" wrote:

I have the following value in a cell:
'TEST14','TEST15','TEST16'

When printing this value to a TXT file, I get:
TEST14','TEST15','TEST16'

How do I get to include the single quote that occurs in the beginning
of the string to be included in the output? Please help.

My code:

Sub Testme
Sheets("sheet01").Activate
gOutfile = "c:/test.txt"
Open gOutfile For Output As #1
For r = 1 To 30
xData = Cells(r, 1).Value
Print #1, xData
Next r
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,117
Default How to read a string in excel and include the single quote

put it back in............

Sub Testme
Sheets("sheet01").Activate
gOutfile = "c:/test.txt"
Open gOutfile For Output As #1
For r = 1 To 30
xData = "'" & Cells(r, 1).Value '<---- change
Print #1, xData
Next r
End Sub


see if that works. i didn't test it.
:)
susan



On Sep 4, 11:14*am, Ricky wrote:
I have the following value in a cell:
'TEST14','TEST15','TEST16'

When printing this value to a TXT file, I get:
TEST14','TEST15','TEST16'

How do I get to include the single quote that occurs in the beginning
of the string to be included in the output? *Please help.

My code:

Sub Testme
* * Sheets("sheet01").Activate
* * gOutfile = "c:/test.txt"
* * Open gOutfile For Output As #1
* * For r = 1 To 30
* * * * xData = Cells(r, 1).Value
* * * * Print #1, xData
* * Next r
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 267
Default How to read a string in excel and include the single quote

Hi ricky
yes i get the same result just using a simple line to test as follows

ActiveCell.Value = Range("b3").Value
"Mike H" wrote:

Ricky,

It works fine for me but I do have 1 comment, you must close the file

Sub Testme()
Sheets("sheet01").Activate
gOutfile = "c:/test.txt"
Open gOutfile For Output As #1
For r = 1 To 30
xData = Cells(r, 1).Value
Print #1, xData
Next r
Close #1
End Sub

Mike

"Ricky" wrote:

I have the following value in a cell:
'TEST14','TEST15','TEST16'

When printing this value to a TXT file, I get:
TEST14','TEST15','TEST16'

How do I get to include the single quote that occurs in the beginning
of the string to be included in the output? Please help.

My code:

Sub Testme
Sheets("sheet01").Activate
gOutfile = "c:/test.txt"
Open gOutfile For Output As #1
For r = 1 To 30
xData = Cells(r, 1).Value
Print #1, xData
Next r
End Sub

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
vlookup and using single quote Bishop Excel Worksheet Functions 2 April 3rd 09 06:02 PM
Writing formula to include quote marks in result Valerie Excel Worksheet Functions 4 February 18th 09 10:01 PM
Remove single quote Avadivelan TCS Excel Worksheet Functions 4 October 5th 06 03:48 PM
How can I get rid of the ' single quote sign in excel worksheet Ivan Excel Worksheet Functions 5 October 21st 05 05:35 AM
Removing single quote from an excel sheet Hari Excel Discussion (Misc queries) 2 December 3rd 04 09:53 PM


All times are GMT +1. The time now is 06:22 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"