Need help with VBA

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
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Not sure where they should be but you probably need some more & "\" & in there

NewFN = "S:\Shared Folders\1-Shanks Docs\Daily Logs\Completed Invoices\Inv" & Range("f9").Value & " -" & Range("b10").Value & Range("f8").Value & ".xlsx
 
Upvote 0

Forum statistics

Threads
1,215,527
Messages
6,125,337
Members
449,218
Latest member
Excel Master

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