Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you! Just one more question, as I still haven't been able to make this
work. Would I just "copy & paste" this code onto the "This Workbook" section on Visual Basic of my file? ---I've Adjusted the names I actually have on my file for the InvWS, Log, and my invoice number cell reference (as well as the suppliers). I greatly appreciate your help with this!. john wrote: sorry for belated reply. Following code increments your invoice sheet after two copies are printed & makes a record of invoice to log worksheet. You will need to add code to update any textbox on your form that displays invoice number. Sub PrintInvoice() Dim invno As Range Dim InvNumber As Long Dim InvWS As Worksheet Dim LogWs As Worksheet Dim Supplier As String Set InvWS = Worksheets("Invoice") Set LogWs = Worksheets("Log") Set invno = InvWS.Range("A1") Supplier = InvWS.Range("A2").Value '<<change as required With invno .NumberFormat = "@" .HorizontalAlignment = xlRight If IsEmpty(.Value) Then InvNumber = 1 .Value = Format(InvNumber, "0000") Else InvNumber = .Value End If InvWS.PrintOut Copies:=2, Collate:=True .Value = Format(InvNumber + 1, "0000") End With With LogWs lr = .Cells(.Rows.Count, 1).End(xlUp).Row + 1 With .Range("A" & lr) .NumberFormat = "@" .HorizontalAlignment = xlRight .Value = Format(InvNumber, "0000") End With .Range("B" & lr).Value = Supplier .Range("C" & lr).Value = Format(Date, "dd/mm/yyyy") End With End Sub Hi, [quoted text clipped - 12 lines] Thank you! -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200908/1 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
referencing another sheet and using auto fill | New Users to Excel | |||
BeforePrint | Excel Programming | |||
Data referencing and auto fill across worksheets in one workbook.. | Excel Worksheet Functions | |||
BeforePrint help | Excel Programming | |||
ADO 2.7 & ADO 2.8 beforeprint | Excel Programming |