VB code help please

Get_Involved

Active Member
Joined
Jan 26, 2007
Messages
383
How do I restructure this part of the code, to put todays year, month, and date, before this part of the code?

Code:
Private Sub Workbook_Open()
 Dim Ans As String
 Ans = MsgBox("Update Invoice Number (???)", vbYesNo + vbInformation)
 If Ans = vbYes Then

Example: 2018121773 , year/month/date,2018/12/17+ 27 the updated number on the end.
This will create a Authorization number.

Code:
With Sheets("Expense Report").Range("H4")
 .Value = .Value + 1

In the complete code I have to manually input the numbers the first time and it increases the end of it.

Code:
Private Sub Workbook_Open()
 Dim Ans As String
 Ans = MsgBox("Update Invoice Number (???)", vbYesNo + vbInformation)
 If Ans = vbYes Then
  With Sheets("Expense Report").Range("H4")
 .Value = .Value + 1

Thanks for any help.
 
The helper cell is to keep track of the trailling number, in this case 47
That way when the workbook opens it will know what the last number used was !
 
Upvote 0

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Sorry I don't understand your last question ?? @Logit and I have provided basically the same code, except for the addition of the helper cell, which I have explained the need for !
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,316
Members
452,634
Latest member
cpostell

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