We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Today function loop

allwork32
allwork32 asked
on
Medium Priority
230 Views
Last Modified: 2012-05-11
Hello Experts

I'm looking for VBA code to do the following:

loop through cells in column "B" starting at "B2;  put a "Today" function in Column M that calculate the dates in column J starting at "J2".  The formula that i'm currently using and auto filling down in column M is =Today()-J2

Thank you
Comment
Watch Question

Try this

Sub Sample()
    Dim Lastrow As Long
   
    Lastrow = Sheets("Sheet1").Range("B" & Rows.Count).en(xlUp).Row
   
    Range("M2").Formula = "=Today()-J2"
   
    Range("M2").AutoFill Destination:=Range("M2:M" & Lastrow), Type:=xlFillDefault
End Sub

Sid
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
I'm getting an error message in the loop.

Author

Commented:
Worked great, thanks
You are welcome :)

Sid
Are you still facing any problems?

Sid
Dirk HaestProject manager
CERTIFIED EXPERT

Commented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.