populate date in first cell based on previous cell plus 30 days

leap out

Active Member
Joined
Dec 4, 2020
Messages
288
Office Version
  1. 2016
  2. 2010
Hello
I want search for the containing in last cell in column B and copy & put in next cell in column A and add 30 days for cells in last cell in column A when show date in adjacent cell in column B without red color , copy to next cells just based on one condition when the date in last cell in column B is matched with date(today) in PC , then should copy to next cells in columns A,B
I want to do that when open workbook automatically .
original


DATE.xlsm
ABCD
1FROMTODEVL
228/07/202327/08/2023
327/08/202326/09/2023
sh


should be
DATE.xlsm
ABCD
1FROMTODEVL
228/07/202327/08/2023
327/08/202326/09/2023
426/09/202326/10/2023
sh

thanks
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
the matter is not easy as you did it .
surely not as you did it.
you misreading this
I want to do that when open workbook automatically .
should be by vba
 
Upvote 0
Let's see what you have got, and what is not working with what you have tried. Your description is lacking some details.
 
Upvote 0
What do you want if you open and close the workbook 10 times in one day? Do you want those calculations happening EVERY time, or just each new month, or each new day?
 
Upvote 0
What do you want if you open and close the workbook 10 times in one day?
if it's matched with date today and open and close every time should not calculate every time , just one time.
just calculation if the date last cell in column B is matched with date in pc then should copy the last cell in column B to next cell in column A and add 30 days to next cell in column A to show in adjacent cell in column B .
the calculation doesn't depends new day or month as you said .
the standard is based on date today in last cell in column B with date today in PC .
 
Upvote 0
I think @duggie33 is asking you to show what vba you have already created?
VBA Code:
Sub ADD_DATE()
Dim lr As Long
lr = Range("b" & Rows.Count).End(xlUp).Row
If Range("b" & lr) = Date Then
Range("a" & lr + 1) = Range("b" & lr)
Range("b" & lr + 1) = Range("a" & lr) + 30
End If
End Sub
result when I run every time
DATE
ABCD
1FROMTODEVL
228/07/202327/08/2023
327/08/202326/09/2023
426/09/202326/09/2023
526/09/202326/10/2023
sh

the row4 shouldn't show
 
Upvote 0
Try this...you may have to remove the "Sheet4".
VBA Code:
Sub ADD_DATE()

    Dim lr As Long
    lr = Sheet4.Range("b" & Rows.Count).End(xlUp).Row

    If Sheet4.Range("b" & lr) = Date Then
        Sheet4.Range("a" & lr + 1) = Sheet4.Range("b" & lr)
        Sheet4.Range("b" & lr + 1) = DateAdd("d", 30, Sheet4.Range("a" & lr + 1))
    End If

End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,224,812
Messages
6,181,088
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