Parse out commas?????

jasgot

New Member
Joined
Jul 16, 2002
Messages
30
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
  5. 2010
Platform
  1. Windows
I use this code, (thanks to this board :)) to name and save my file based on user input. How can I yank out any commas that get put into the VB_Trigger, which will become the filename?

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = Range("VB_Trigger").Address Then
ThisFile = Range("VB_Trigger").Value
ActiveWorkbook.SaveAs Filename:="P:SYO Sales DocsQuotesSales" & ThisFile
ActiveWorkbook.Windows(1).Caption = ActiveWorkbook.FullName
End If
End Sub


Thanks!
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hi jasgot,

Try:

<pre>Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim ThisFile As String

If Target.Address = Range("VB_Trigger").Address Then
ThisFile = Range("VB_Trigger").Value
ThisFile = Application.Substitute(ThisFile, ",", "")
ActiveWorkbook.SaveAs FileName:="P:SYO Sales DocsQuotesSales" & ThisFile
ActiveWorkbook.Windows(1).Caption = ActiveWorkbook.FullName
End If

End Sub</pre>
HTH

PS If "Sales" is a sub-directory then you need another backslash at the end, before the quotes end.
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,684
Members
449,116
Latest member
HypnoFant

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top