View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone[_2_] Jim Cone[_2_] is offline
external usenet poster
 
Posts: 1,549
Default macros on an invoice

If you look at the very first line of the code, it says Workbook_Open.
That means the invoice number is incremented when the workbook first opens.

To change it so the number increases when a particular cell is changed will require
a rewrite of the code - probably into a Worksheet_Change(ByVal Target As Range)
sub located in the module attached to Sheet "Invoice".

Also, the last line in your post doesn't seem to have anything to do with
what comes before... update a date?... get rid of the code?
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Heather C"
wrote in message
I found a web sit that I copyed the data off of so it could have my invoice
number update automaticaly. I was wondering if thier was a way that it
wouldn't update untill I entered something into a specefic cell. What I mean
is I don't want the invoice number to update untill I enter the cumber number
inthe field. The code i'm using is
Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long

With ThisWorkbook.Sheets("Invoice")
With .Range("g6")
If IsEmpty(.Value) Then
.Value = Date
.NumberFormat = "mmmmmmmmmm dd, yyyy"
End If
End With
With .Range("g5")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY,
nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "0000")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
End With
End Sub

I really don't need it to update the date I just didn't know how to get rid
of this code