utterly confused
New Member
- Joined
- Nov 23, 2005
- Messages
- 28
Trying to create, with much stress and anxiety, an order form with automated numbering. Being a complete and utter novice at VBA I copied the following from somewhere on this web site.
Private Sub Workbook_Open()
Dim nmbr As Long
Dim fNum As Integer
fNum = FreeFile
Open ThisWorkbook.Path & "\" & "lastvalue.txt" For Random As #fNum Len = Len(nmbr)
Get #fNum, 1, nmbr
nmbr = nmbr + 1
Put #fNum, 1, nmbr
Close #fNum
If Sheets("Sheet1").Range("A1").Value = "" Then Sheets("Sheet1").Range("A1").Value = nmbr
End Sub
I changed A1 to H13 as H13 is the cell I need the order number to go into.
My problem is a couple of things not working as they should.
Firstly I need to have the notepad save to a “public” drive and not my local drive. When I try to do this it does not seem to like it.
Secondly I need to change the number in the notepad to reflect what invoice number we are up to such as 11780, however the number on the invoice form comes up as something unrelated and much much higher. When I go back to Notepad the numbers appear spaced, ie: y 1 1 7 8 0, and a letter y has been added.
Lastly is it possible to run a macro to prompt the operator to save not as a template but to a file?
As I said am a complete novice so hope this all makes sense, thanks in anticipation of some stress relief!!
Private Sub Workbook_Open()
Dim nmbr As Long
Dim fNum As Integer
fNum = FreeFile
Open ThisWorkbook.Path & "\" & "lastvalue.txt" For Random As #fNum Len = Len(nmbr)
Get #fNum, 1, nmbr
nmbr = nmbr + 1
Put #fNum, 1, nmbr
Close #fNum
If Sheets("Sheet1").Range("A1").Value = "" Then Sheets("Sheet1").Range("A1").Value = nmbr
End Sub
I changed A1 to H13 as H13 is the cell I need the order number to go into.
My problem is a couple of things not working as they should.
Firstly I need to have the notepad save to a “public” drive and not my local drive. When I try to do this it does not seem to like it.
Secondly I need to change the number in the notepad to reflect what invoice number we are up to such as 11780, however the number on the invoice form comes up as something unrelated and much much higher. When I go back to Notepad the numbers appear spaced, ie: y 1 1 7 8 0, and a letter y has been added.
Lastly is it possible to run a macro to prompt the operator to save not as a template but to a file?
As I said am a complete novice so hope this all makes sense, thanks in anticipation of some stress relief!!