Need to create a prompt for save as function in current macro.

JDHarris

New Member
Joined
Apr 21, 2017
Messages
10
Trying to figure out how to create a prompt to rename and save CSV file in current macro to a specified directory and close. Any help would get me over this hump so I can move on in this project.


Dim main_size
Dim EndLine

Worksheets(1).Activate
Worksheets(1).Range("A1:B7000").Select


Selection.Copy
Workbooks.Add
ActiveSheet.Paste
main_size = Selection.Rows.Count

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=Environ("userprofile") & "\My Documents" & _
"\Online.csv", FileFormat:= _
xlCSV, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
, CreateBackup:=False
Application.DisplayAlerts = True
ActiveWorkbook.Close
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hi Harris, welcome.

Try this on a sample data or a copy of original data.
Code:
Dim main_size
Dim EndLine
Worksheets(1).Activate
Worksheets(1).Range("A1:B7000").Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
main_size = Selection.Rows.Count
Application.DisplayAlerts = False

[COLOR=#ff0000]newname = inputbox("Please Specify a new name to the file")[/COLOR]
ActiveWorkbook.SaveAs Filename:=Environ("userprofile") & "\My Documents" & "\" & [COLOR=#ff0000]newname[/COLOR] & ".csv", FileFormat:= xlCSV

Application.DisplayAlerts = True
ActiveWorkbook.Close
 
Upvote 0

Forum statistics

Threads
1,215,530
Messages
6,125,350
Members
449,220
Latest member
Edwin_SVRZ

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