Excel VBA Macro: Save As Dialog (Allow User to Select Saved File Location)

Описание к видео Excel VBA Macro: Save As Dialog (Allow User to Select Saved File Location)

Excel VBA Macro: Save As Dialog (Allow User to Select Saved File Location). In this video, we go over how to create a macro that allows a user to select a location to save a particular file. We write code that, when run, will prompt the user to select a save file name and location for a workbook (created from copying the activesheet), and then the save is executed.

Code (YouTube doesn't allow brackets; so LT and GT are used for less than and greater than, respectively):

Sub allow_user_to_select_save_location()

Dim region As String
Dim selection As Variant

region = ActiveSheet.Cells(2, 2).Text
ActiveSheet.Copy

selection = Application.GetSaveAsFilename( _
FileFilter:="Excel Workbook (*.xlsx), *.xlsx", _
Title:="Please Select Location to Save File", _
InitialFileName:="Region Report " & region & " " & _
Format(Date, "mm-dd-yy"))

If selection LTGT False Then
ActiveWorkbook.SaveAs Filename:=selection
End If

ActiveWorkbook.Close savechanges:=False

End Sub

Data used in this video:
https://gsociology.icaap.org/datauplo...

#ExcelVBA #ExcelMacro

Комментарии

Информация по комментариям в разработке