vba - Excel output to file -


i've got list of sql commands in excel sheet. similar this:

update table1 set data =100 point=123
update table1 set data =100 point=421
update table1 set data =100 point=12333
update table1 set data =100 point=90

'4'

where 4 represents count of commands. need them export .sql file , save. i've found great tutorial helped me lot @ end ot there line saying not worry double quotes.
do.
code looks this:

sub opentextfile()

dim filepath string
dim lastrow long
dim celldata string

filepath = thisworkbook.path & "\" & "update.sql"
lastrow = activesheet.usedrange.specialcells(xlcelltypelastcell).row

open filepath output #1
= 1 lastrow
celldata = activecell(i).value
write #1, celldata
next i
close #1

end sub

and exports data can't find way rid of these quotes beacouse output looks like:

"update table1 set data =100 point=123"

and on.

change write #1, celldata print #1, celldata

that worked me in tests. further reading here: https://msdn.microsoft.com/en-us/library/office/gg264278.aspx


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -