ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Alter data or start macro from a date formula (https://www.excelbanter.com/excel-programming/336265-alter-data-start-macro-date-formula.html)

Davidm

Alter data or start macro from a date formula
 
At present when I change the start date in one cell and end date in another
cell the number of weeks difference between the dates is automatically worked
out by a formula in yet another cell.

I have recorded macros to alter data in different sheets of the workbook
according to the number of weeks difference. But I would like to do it
automatically on entering the dates.

Bernie Deitrick

Alter data or start macro from a date formula
 
David,

You could use the worksheet change event, but we would need a _little_ more info to help you figure
out what to do....

HTH,
Bernie
MS Excel MVP


"DavidM" wrote in message
...
At present when I change the start date in one cell and end date in another
cell the number of weeks difference between the dates is automatically worked
out by a formula in yet another cell.

I have recorded macros to alter data in different sheets of the workbook
according to the number of weeks difference. But I would like to do it
automatically on entering the dates.




Jim Thomlinson[_4_]

Alter data or start macro from a date formula
 
I would recommend using the on change event to fire the existing macros
something like this...

Private Sub Worksheet_Change(ByVal Target As Range)
if target.address = "$A$1" or target.address = "$A$2" then _
Call MyMacro()
End Sub

With this code if either cells A1 or A2 are changed then MyMacro is called.
This code needs to be inserted into the sheet with the dates on it. (Right
click the tab and select view code). All you need to do is change the cell
references and "MyMacro" and you are off to the races...
--
HTH...

Jim Thomlinson


"DavidM" wrote:

At present when I change the start date in one cell and end date in another
cell the number of weeks difference between the dates is automatically worked
out by a formula in yet another cell.

I have recorded macros to alter data in different sheets of the workbook
according to the number of weeks difference. But I would like to do it
automatically on entering the dates.



All times are GMT +1. The time now is 10:39 AM.

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