VBA Saving excel with some constrains

hazayah

New Member
Joined
Jul 31, 2019
Messages
2
Dear All,

I have seen the great value of this website I'm not really experience with VBAbut relaying too much on MREXCEL

i'm adding a code to for a button on the excel so when you click on it


It should openthe saving as box with a specific name reading form a cell

I found the acode but my issue is the name not showing while selecting a place to save onlyafter I save it

Please help meto re type the code properly

Thank you inadvance

Code:
Sub save_workbook()
Dim FilePath As String

ActiveWorkbook.SaveAs filename:=Range("a1"), fileformat:=52
FilePath = Application.GetSaveAsFilename
End Sub
 

Some videos you may like

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

theBardd

Rules violation
Joined
Jan 21, 2012
Messages
912
Try this

Code:
Dim FilePath As String
    With Application.FileDialog(msoFileDialogSaveAs)
    
        .InitialFileName = Range("A1").Value
        If .Show Then
        
            ActiveWorkbook.SaveAs Filename:=.SelectedItems(1), FileFormat:=52
        End If
    End With
 
Last edited:

hazayah

New Member
Joined
Jul 31, 2019
Messages
2
Try this

Code:
Dim FilePath As String
    With Application.FileDialog(msoFileDialogSaveAs)
    
        .InitialFileName = Range("A1").Value
        If .Show Then
        
            ActiveWorkbook.SaveAs Filename:=.SelectedItems(1), FileFormat:=52
        End If
    End With

thank you , it works
 

Watch MrExcel Video

Forum statistics

Threads
1,099,573
Messages
5,469,473
Members
406,655
Latest member
pwilson06

This Week's Hot Topics

Top