Open Workbook at end of macro

JOSTERBAUER

Board Regular
Joined
Jan 17, 2005
Messages
101
I have this macro up and running, but it will not open the original workbook back up after I run the macro. This is the function I can not get to finish with (Workbooks.Open Filename:= _
"C:\PDF FILES\INVOICE TRACKER\Invoice.Xls" )
Can anyone help me with this. You have been great with the other posts I have. This forum is great.

Sub Newjob()


Dim x As String
Dim cell As String
Dim counter As Integer
Dim Invoicenum As String
Dim Name As String
Dim amount As String

Invoicenum = Range("D5")
Name = Range("A10")
amount = Range("d35")


If Name <> "" Then

Workbooks.Open Filename:= _
"C:\PDF FILES\INVOICE TRACKER\Invoice tracker.Xls"
Sheets("2005 INVOICES").Select

Range("A2").Activate

For counter = 1 To 200
If "" = ActiveCell.Value Then
ActiveCell.Value = Invoicenum
cell = "A" & ActiveCell.Row
Range(cell).Offset(0, 1).Value = Name
Range(cell).Offset(0, 2).Value = Date
Range(cell).Offset(0, 7).Value = amount
GoTo escape1
Else: cell = "A" & ActiveCell.Row + 1
Range(cell).Activate
End If
Next
escape1:
End If

ActiveWorkbook.Save
ActiveWorkbook.Close
ChDir "C:\PDF FILES\INVOICE TRACKER\INVOICES"
ActiveWorkbook.SaveAs Range("D5")
ActiveWorkbook.Close
ActiveWorkbook.Save
'ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True



Workbooks.Open Filename:= _
"C:\PDF FILES\INVOICE TRACKER\Invoice.Xls"
End Sub
 
Here is the final code that works out just perfect.
If anyone wants to charge out invoices, and keep track of the invoice, the person charged to, date charged, date due, and so on, let me know. I will get the file to you, so you could change as needed. You can thank Erik as well.

Sub invoice()


Dim x As String
Dim cell As String
Dim counter As Integer
Dim Invoicenum As String
Dim Name As String
Dim amount As String
Dim invoice As String

Invoicenum = Range("D5")
Name = Range("A10")
amount = Range("d35")

If Name <> "" Then
Workbooks.Open Filename:="C:\PDF FILES\INVOICE TRACKER\Invoice tracker.Xls"
tracker = ActiveWorkbook.Name
invoice = ThisWorkbook.Name

Range("A2").Activate

With Range("A65536").End(xlUp).Offset(1, 0)
.Value = Invoicenum
.Offset(0, 1).Value = Name
.Offset(0, 2).Value = Date
.Offset(0, 7).Value = amount
End With
End If
Workbooks(tracker).Close True

ChDir "C:\PDF FILES\INVOICE TRACKER\INVOICES"

Workbooks(invoice).SaveAs Range("D5")
invoice = ActiveWorkbook.Name
'ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

Workbooks.Open Filename:="C:\PDF FILES\INVOICE TRACKER\Invoice.Xls"
Workbooks(invoice).Close True


End Sub
 
Upvote 0

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
That's a beautiful offer!
Please send it. I'm curious :oops:

kind regards,
Erik

EDIT
TIP!! posting code ==> select your code, and click on the button "code"
that's producing a more readable layout
 
Upvote 0

Forum statistics

Threads
1,224,802
Messages
6,181,053
Members
453,014
Latest member
Chris258

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