save a copy of a workbook -vba

avishain

Board Regular
Joined
Dec 14, 2010
Messages
75
hi,

im usnig excel 2007.

i want to create a button which will do the following:

1.once i click it- it will pop up a window and ask me to fill in a number ("pls enter your number").

i need "ok" and "cancel" option (if i hit the "cancel" button so nothing happend and im back to my excel sheet).

2.if i pressed "ok" so excel will show me my folders on my computers and there i want to save the copy.

3. this copy will have the name according to what i have entered (the number).


for instance,if excel askes me -("pls enter your number") and i typed 1111

so eventually ill have a copy named 1111.xlsx in the spesific folder the i chose before.


thanks u very much
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
You need something along these lines. Not checked

Sub copyWorkBook1()

Dim strName As Integer
strName = InputBox("Please Enter your number", "Test", , 1000, 1000)
fileSaveName = Application.GetSaveAsFilename( _
fileFilter:="Excel Workbooks (*.xlsx), *.xlsx")
If fileSaveName <> False Then
MsgBox "Save as " & fileSaveName
End If

End Sub
 
Upvote 0
hey,

thank u for helping.


it works great except of that the filename of the copy isnt the number that i entered.


when the inputbox asks me "enter your number" ,i want that the same number will be used as the file name.

for instace, if i entered 1111,the copy of the file will be saved as 1111.xlsx


thank you
 
Upvote 0
I have no idea why the other doesn't work... but i use this one to save the file as another name with an input box.

Code:
sub save_it()
Dim fname
fname = inputbox ("Enter a filename")
if fname <>"" then
fname = fname & ".xlsx"
ActiveWorkbook.SaveAs Filename:=fname
end if
end sub
 
Upvote 0

Forum statistics

Threads
1,224,575
Messages
6,179,637
Members
452,934
Latest member
Jdsonne31

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