Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove double quotation from write statement in vba

Tags:

excel

vba

This code will write log file to LogFilePath, and generate output as below. StarRange and EndRange is a variable which value will populate from other function.

"Start postion",A1 "End position",B100  ---Code----------------- Sub WriteLogFile()  Dim FilePath As String   LogFilePath = WriteTextBox.Text  LogFilePath = LogFilePath & ".log" Open LogFilePath For Output As #2  Write #2, "Start postion"; StarRange Write #2, "End position"; EndRange Close #2  MsgBox FinalFileName  End Sub 

My question is how can I remove double quotation mark from output and produce output as below. Thanks

Start position = A1 End position = B100 
like image 246
user1902849 Avatar asked Nov 16 '13 09:11

user1902849


People also ask

How do I remove quotation marks in VBA?

Cells. Replace What:="", Replacement:="", LookAt:=xlPart, MatchCase:=False 'Replaces the quotes.

How do you get rid of double quotes in text?

Option 1: Remove any double quotes in a text string with replace('my string','"',''). This will substitute any instance of a double quote anywhere in the string with an empty string.

How do you remove quotation marks from a string?

To remove double quotes just from the beginning and end of the String, we can use a more specific regular expression: String result = input. replaceAll("^\"|\"$", ""); After executing this example, occurrences of double quotes at the beginning or at end of the String will be replaced by empty strings.


1 Answers

Write is a special statement designed to generate machine-readable files that are later consumed with Input.

Use Print to avoid any fiddling with data.

Print #2, "Start postion = "; StarRange Print #2, "End position = "; EndRange 
like image 76
GSerg Avatar answered Sep 21 '22 20:09

GSerg