ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   macro to save file automaticaly? (https://www.excelbanter.com/excel-discussion-misc-queries/24167-macro-save-file-automaticaly.html)

david

macro to save file automaticaly?
 
I already have a button with a macro to hide the empty rows. With this same
button I want to save the file automatically after the rows are hidden. The
name of the saved file should be the word in cell (€œsheet3€ €œA1€).

The first macro works the second doesnt.

Can someone please help me to fix the second and to combine the to.

Thanks!!!


Private Sub CommandButton1_Click()

Dim X As Integer

For X = 5 To 150

If Cells(X, 1).Value = 0 Then
Rows(X).Hidden = True
End If

Next X
End Sub


Sub SaveArchive()

ArchivePath = "Z:\david\werkbonnen\"
WorkBookName = Worksheets(€œprint€).Range(€œA1€).Value

FName = ArchivePath + WorkBookName
ActiveWorkbook.SaveAs Filename:=FName
End Sub


Davie

When I paste you code into a macro sheet the '' '' around print and A1 each
become a pair of 's. That is
you should always use Shift and the 2 key from the alpha part (double quote)
of your keyboard rather than ' (single quote) twice. That might not be the
problem but why else would it change for my copy and paste of your code?



david wrote in message
...
I already have a button with a macro to hide the empty rows. With this same
button I want to save the file automatically after the rows are hidden. The
name of the saved file should be the word in cell (€œsheet3€ €œA1€).

The first macro works the second doesnt.

Can someone please help me to fix the second and to combine the to.

Thanks!!!


Private Sub CommandButton1_Click()

Dim X As Integer

For X = 5 To 150

If Cells(X, 1).Value = 0 Then
Rows(X).Hidden = True
End If

Next X
End Sub


Sub SaveArchive()

ArchivePath = "Z:\david\werkbonnen\"
WorkBookName = Worksheets(€œprint€).Range(€œA1€).Value

FName = ArchivePath + WorkBookName
ActiveWorkbook.SaveAs Filename:=FName
End Sub





All times are GMT +1. The time now is 01:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com