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

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
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,215,046
Messages
6,122,852
Members
449,096
Latest member
Erald

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