katiapro93
Board Regular
- Joined
- Jun 25, 2009
- Messages
- 140
I have almost figured it out, but I have one hang up.
I am working with a spreadsheet that I fill out and when I press my macro assigned button, it copies my worksheet to a blank workbook, saves the copy, using "Save as", to a designated file, and returns to the original one to do further action.
I am getting stuck after I give it a file name. Can anyone help?
Here is my present code:
Sub PostToRegister()
Dim WS1 As Worksheet
Dim WS2 As Worksheet
Set WS1 = Worksheets("Invoice")
Set WS2 = Worksheets("Register")
'Figure out which row is the next row
NextRow = WS2.Cells(Rows.Count, 1).End(xlUp).Row + 1
'Write the important values to Register
WS2.Cells(NextRow, 1).Resize(1, 5).Value = Array(WS1.Range("f9"), WS1.Range("f8"), _
WS1.Range("b10"), WS1.Range("B13"), WS1.Range("f46"))
End Sub
Sub NextInv()
Range("F9").Value = Range("f9").Value + 1
Range("B10:c10").ClearContents
Range("b18:f45").ClearContents
End Sub
Sub SaveInvWithNewName()
Dim NewFN As Variant
PostToRegister
'Copy Invoice to a new workbook
ActiveSheet.Copy
NewFN = "S:\Shared Folders\1-Shanks Docs\Daily Logs\Completed Invoices\Inv" & Range("f9").Value & " -" & Range("b10").Value & Range("f8").Value & ".xlsx"
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWorkbook.Close
NextInv
End Sub
I am working with a spreadsheet that I fill out and when I press my macro assigned button, it copies my worksheet to a blank workbook, saves the copy, using "Save as", to a designated file, and returns to the original one to do further action.
I am getting stuck after I give it a file name. Can anyone help?
Here is my present code:
Sub PostToRegister()
Dim WS1 As Worksheet
Dim WS2 As Worksheet
Set WS1 = Worksheets("Invoice")
Set WS2 = Worksheets("Register")
'Figure out which row is the next row
NextRow = WS2.Cells(Rows.Count, 1).End(xlUp).Row + 1
'Write the important values to Register
WS2.Cells(NextRow, 1).Resize(1, 5).Value = Array(WS1.Range("f9"), WS1.Range("f8"), _
WS1.Range("b10"), WS1.Range("B13"), WS1.Range("f46"))
End Sub
Sub NextInv()
Range("F9").Value = Range("f9").Value + 1
Range("B10:c10").ClearContents
Range("b18:f45").ClearContents
End Sub
Sub SaveInvWithNewName()
Dim NewFN As Variant
PostToRegister
'Copy Invoice to a new workbook
ActiveSheet.Copy
NewFN = "S:\Shared Folders\1-Shanks Docs\Daily Logs\Completed Invoices\Inv" & Range("f9").Value & " -" & Range("b10").Value & Range("f8").Value & ".xlsx"
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWorkbook.Close
NextInv
End Sub