VBA Automatically copy Cell value to another Cell based on the results of a formula

kopower

Board Regular
Joined
Nov 29, 2014
Messages
52
Hi I have been struggling trying to create this code for the last two weeks and am hoping someone can help me :).
I want to copy the value (Date) and pastespecial as a result of a formula.
For instance I have formula in B2 which is IF(B3="","",IF(B3>=80%,TODAY(),"")) as soon as the result of the formula shows today's date I want it to automatically copy the value into B4, in C2 formula IF(c3="","",IF(c3>=80%,TODAY(),"")) as soon as the result shows today's date I want it to automatically copy the value into c4, in d2 formula IF(d3="","",IF(d3>=80%,TODAY(),"")) as soon as the result shows today's date I want it to automatically copy the value into d4 , etc for e, f, and g.

Hoping that someone will be able to help me on this as I really been struggling trying to get this to work.

Thank you in advance for anybody's help on this.

Regard.

KO
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
I don't know if you can use a Worksheet_Change event code to do that if the values in B2 and B3 are both derived by calculation. Excel is geared to ignore calculations for the Change event.
Code:
Private Sub Worksheet_Calculate()
Application.EnableEvents = False
    If Range("B3").Value = Date Then Range("B4") = Date
    If Range("C3").Value = Date Then Range("C4") = Date
Application.EnableEvents = True
End Sub
I'm not sure I understand which value you wanted copied, but you can work with the code to get the right range. Just notice you wanted this for the entire data range. Will post that later.
 
Last edited:
Upvote 0
This covers columns B:G
Code:
Private Sub Worksheet_Calculate()
Application.EnableEvents = False
    For Each c In Range("B3:G3")
        If c.Value = Date Then c.Offset(1) = Date
    Next
Application.EnableEvents = True
End Sub
In case it was the row 2 value you wanted copied then use this one.
Code:
Private Sub Worksheet_Calculate()
Application.EnableEvents = False
    For Each c In Range("B3:G3")
        If c.Value = Date Then c.Offset(1) = c.Offset(-1).Value
    Next
Application.EnableEvents = True
End Sub
 
Upvote 0
Hi JLGWhiz that works great is it also possible to have something that if c.Value does not equal Date that it is blank? Therefore it would switchback and forth depending on the result of B3:G3
 
Upvote 0
Hi JLGWhiz I just figured out the second question that I had sent you. So please ignore previous post.

Thank you so much for your answer I spend over 40 hours trying to figure this out. You are fantastic and thank you again for all your help!!!!!!
 
Upvote 0
Hi JLGWhiz I just figured out the second question that I had sent you. So please ignore previous post.

Thank you so much for your answer I spend over 40 hours trying to figure this out. You are fantastic and thank you again for all your help!!!!!!

You're welcome,
regards, JLG
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,257
Members
449,075
Latest member
staticfluids

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