Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello all.
I have a macro in which I save the document creating the filename based on selected text in the document. However in some cases, the selected text looks like "995451/U." Obviously I cannot save using this name. I would like to convert this to "995451-U" for saving purposes only but NOT in the document. How can I do this? Thanks, KS |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
if the format is always the same (six numbers, slash, letter) you could
use Dim MyFileName as Variant Dim SelectedText as Variant SelectedText = 'wherever that cell/text is MyFileName = Left(SelectedText, 6) & "-" & Right(SelectedText, 1) ActiveDocument.SaveAs: MyFileName this is not tested & may contain errors (i'm no guru!) but the concept should work. susan |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, that worked just fine. I have a brain cloud today & cound't
think of a way to do it. Thanks again. KS Susan wrote: if the format is always the same (six numbers, slash, letter) you could use Dim MyFileName as Variant Dim SelectedText as Variant SelectedText = 'wherever that cell/text is MyFileName = Left(SelectedText, 6) & "-" & Right(SelectedText, 1) ActiveDocument.SaveAs: MyFileName this is not tested & may contain errors (i'm no guru!) but the concept should work. susan |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
one way
Sub test() Dim mystring As String, newstring As String mystring = "995451/U" newstring = Replace(mystring, "/", "-", 1) MsgBox newstring End Sub -- Gary "KS" wrote in message oups.com... Hello all. I have a macro in which I save the document creating the filename based on selected text in the document. However in some cases, the selected text looks like "995451/U." Obviously I cannot save using this name. I would like to convert this to "995451-U" for saving purposes only but NOT in the document. How can I do this? Thanks, KS |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel-Match 1st text character in a string to a known character? | Excel Worksheet Functions | |||
How do I replace last numeric string from a alphanumeric string? | Excel Discussion (Misc queries) | |||
Function to return Character Position of Xth character within a string | Excel Programming | |||
How do I replace * as a character in a string in Excel? | Excel Programming | |||
How to replace this character ... | Excel Programming |