add number based on date

Trevor3007

Well-known Member
Joined
Jan 26, 2017
Messages
675
Office Version
  1. 365
Platform
  1. Windows
hi,

i know what i want it to do, but dont know if its viable

I have to invoice the customer each week . So for example :-

WC 11//2/19 has invoice number 9

is it possible to automate the invoice number (located in cell g1) to change accordingly based on the WC date (located in cell b4)?

so WC :-

18/2/19 invoice number = 10
25/2/19 ---||----- = 11
04/3/19 ---||----- = 12

ETC

i hoping some can sort.

Kindest regards & MTIA
Trevor3997
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hello Trevor,

I don't know what WC is supposed to represent but you could try the following Worksheet_Change event code:-


Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Intersect(Target, Range("B4")) Is Nothing Then Exit Sub
If Target.Count > 1 Then Exit Sub

If IsDate(Target) Then
Range("G1").Value = Range("G1").Value + 1
End If

End Sub

To implement this code:-

- Right click on the sheet tab.
- Select "View Code" from the menu that appears.
- In the big white code field that then appears, paste the above code.

Please test the code in a copy of your workbook first.

I hope that this helps.

Cheerio,
vcoolio.
 
Upvote 0
How about


Excel 2013/2016
BC
411/02/20199
518/02/201910
625/02/201911
704/03/201912
Prices
Cell Formulas
RangeFormula
C4=WEEKNUM(B4)+2
 
Upvote 0
Hi,

Thank you for your help. I tried but it did not work... Fluff also said try/use =WEEKNUM(B4)+2 and it did.

I do appreciate your help & hope you have a good weekend.

KR
Trevor3007

 
Upvote 0
Hello Trevor,

I don't know what WC is supposed to represent but you could try the following Worksheet_Change event code:-


Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Intersect(Target, Range("B4")) Is Nothing Then Exit Sub
If Target.Count > 1 Then Exit Sub

If IsDate(Target) Then
Range("G1").Value = Range("G1").Value + 1
End If

End Sub

To implement this code:-

- Right click on the sheet tab.
- Select "View Code" from the menu that appears.
- In the big white code field that then appears, paste the above code.

Please test the code in a copy of your workbook first.

I hope that this helps.

Cheerio,
vcoolio.




WC = week commencing :}
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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