Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EXCEL code need help 1

Status
Not open for further replies.

min460120

Programmer
Joined
Jun 23, 2001
Messages
9
Location
US
Hi,

I wrote code to read information from worksheet and put
output to .txt files. The output is SQL statements.
But the output has " " in between.
For example the output like:
"Update table set person_id = 55 Where dept_id = 22"
How to get rid of " "???



Very appreciate your help.





 
Here is a sample that removes all of the spaces in a string.
Code:
Sub RemoveSpaces()
    Dim sText As String, s1 As String, iPos As Integer
    sText = "123 789"
    MsgBox "Before: " & sText
    iPos = InStr(1, sText, " ")
    Do While iPos > 0
        s1 = s1 & Left(sText, iPos - 1)
        sText = Right(sText, Len(sText) - iPos)
        iPos = InStr(1, sText, " ")
    Loop
    s1 = s1 & sText
    MsgBox "After: " & s1
End Sub
 
I'm not sure if you're asking to remove spaces or if you're asking how to remove the quotation marks?

Since SQL without spaces doesn't fly, and since I've encountered the 'wish I didn't have quotes in my .txt file' issue before, here's my response...

Use "Print #1" instead of "Write #1" when writing to your text file. "Write" puts quotes and commas in the file, "Print" leaves it clean.





 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top