ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Increasing the date with a Macro (https://www.excelbanter.com/excel-programming/298996-increasing-date-macro.html)

mattwilsonuk

Increasing the date with a Macro
 
In Cell *A1* i have a date. Cell B1 says "=A1"

I run a macro and added +7 to make cell B1 read "=A1+7".

When I run the macro again nothing happens.

I need to be able to run a simple macro and be able to increase th
date by 1 week each time the macro is run.

Can anyone help?

Thanks

Mat

--
Message posted from http://www.ExcelForum.com


Trevor Shuttleworth

Increasing the date with a Macro
 
Matt

correct me if I'm wrong but A1 hasn't changed. So if you keep setting B1 to
read "=A1+7" you're going to keep getting the same answer.

I think you need to change the increment: first time through, add 7; second
time through, add 14; and so on.

Regards

Trevor


"mattwilsonuk " wrote in
message ...
In Cell *A1* i have a date. Cell B1 says "=A1"

I run a macro and added +7 to make cell B1 read "=A1+7".

When I run the macro again nothing happens.

I need to be able to run a simple macro and be able to increase the
date by 1 week each time the macro is run.

Can anyone help?

Thanks

Matt


---
Message posted from http://www.ExcelForum.com/




Charles

Increasing the date with a Macro
 
Matt,

Are both A1 and B1 formated for Dates?
If so in cell B1= A1+7 it should increase 1 week. However if the dat
in A1 stays the same then no matter how many time you run your macr
the date will alway be the same.

HTH

Charle

--
Message posted from http://www.ExcelForum.com


cucchiaino

Increasing the date with a Macro
 

"mattwilsonuk " ha scritto nel
messaggio ...
In Cell *A1* i have a date. Cell B1 says "=A1"

I run a macro and added +7 to make cell B1 read "=A1+7".

When I run the macro again nothing happens.

I need to be able to run a simple macro and be able to increase the
date by 1 week each time the macro is run.

Can anyone help?



.....
x = 7
Range("B1").FormulaR1C1 = "=RC[-1]+" & x
......




mattwilsonuk[_2_]

Increasing the date with a Macro
 
The date in A1 remains the same throughout.

I was hoping the Macro would create something as crude as

=a1+7+7+7+7+7+7+7+7+7+7+7" depending on the number of times I ran th
macro.

Is there another function I can use to acheive the desired result?

Thx for your input

Mat

--
Message posted from http://www.ExcelForum.com


mattwilsonuk[_3_]

Increasing the date with a Macro
 
How can i make the macro run in increments?

Where does that formula x=7 range.... go?

Thx

Mat

--
Message posted from http://www.ExcelForum.com


cucchiaino

Increasing the date with a Macro
 

"mattwilsonuk " ha scritto nel
messaggio ...
How can i make the macro run in increments?

Where does that formula x=7 range.... go?


.....
x = Range("B1")
Range("B1").FormulaR1C1 = "=RC[-1]+" & 7
.....



mattwilsonuk[_4_]

Increasing the date with a Macro
 
Isnt that VBA script because ive not really gone that far into excel an
cant say i know a great del about it - my macro is being created when
to to tools - macro - record new macro.

Mat

--
Message posted from http://www.ExcelForum.com


mattwilsonuk[_5_]

Increasing the date with a Macro
 
I really appreciate you helping me out and ive been tinkering with th
formala you gave me - been moving it around.

I dont know what to do with it tho - I put it somewhere when i run th
macro?

Mat

--
Message posted from http://www.ExcelForum.com


Bob Phillips[_6_]

Increasing the date with a Macro
 
Go into the VB IDE (Alt-F11)
Insert a new code module (InsertModule)
Add this code

Sub Add7()
If Range("B1").Value = "" Then
Range("B1").VAlue = Range("A1").Value
Else
Range("B1").Value= Range("B1").Value + 7
End If
Range("B1").Numberformat = "dd mmm yyyy"
End Sub

Then every time you want to increase it, run the Sub acelled Add7.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"mattwilsonuk " wrote in
message ...
Isnt that VBA script because ive not really gone that far into excel and
cant say i know a great del about it - my macro is being created when i
to to tools - macro - record new macro.

Matt


---
Message posted from http://www.ExcelForum.com/




mattwilsonuk[_6_]

Increasing the date with a Macro
 
Fantastic

Thank you Bob - Perfect.

Mat

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 12:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com