Young whiz brain required

mikemcbain

Board Regular
Joined
Nov 14, 2005
Messages
152
Office Version
  1. 365
Platform
  1. Windows
I have an extensive macro that builds a database from a number of daily files but it requires me to type a negative number into cell C23 and then I must click a button to run my macro.

These negative numbers represent each past day eg. -2 produces the info for the day before yesterday and -365 produces the info for this day last year etc .

I want the macro to run unattended overnight but for the life of me I cannot work out how to tell it to change C23 from say -33 to -34 and then re-run the macro?

Sounds so simple but my old brain cannot do it so perhaps some young whiz can help me?

Mike.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Not sure that I follow, but could you not simply run a timer macro say every hour or 2 hours
Maybe

If your macro is called MM1

Insert in 1st line of code in MM1

Code:
Application.OnTime Now + TimeValue("01:00"), "MM1"

Then in the Thisworkbook module add the following macro.

Code:
Private Sub Workbook_Open()
Call MM1
End Sub
 
Upvote 0
Try

Code:
For i = -33 to -34 Step -1
    Range("C3").Value = i
    Call yourMacro
Next i

or


Code:
With Range("C3")
    .Value = -32
    Do
        .Value = .Value - 1
        Call YourMacro
    Loop Until .Value = -34
End With
 
Upvote 0
And a thank you to Michael M too!
Your suggestions have prompted me to look deeper for a couple of other problems I have.

Best regdrs

Mike
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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