View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLatham JLatham is offline
external usenet poster
 
Posts: 2,203
Default Code in a macro to branch to another macro?

Do you have any code written at all yet? First, I'd advise on not using
"Weekday" as the name of a macro (and to a lesser degree I wouldn't use
Sunday either). Perhaps something like "ProcessSundays" and "ProcessWeedays".

But to your specific question:
Sub MakeTheDecision()
If ThisWorkbook.Worksheets("SheetName").Range("D5") = _
"Sunday" Then
ProcessSundays
Else
ProcessWeekdays
End If
End Sub

That code assumes that it is in the same module with the two referenced Subs.

"Kevryl" wrote:

I wonder if someone can help me with a little code for inclusion in a macro?
It needs to do the following:

€śIf cell in column D on this row = "Sunday", perform Macro €śSunday€ť,
otherwise execute macro €śWeekday€ť€ť

Background info:

I run an accounting system on a series of worksheets. The Cash Journal
dynamically applies the week of the year and day of the week (based on the
first date in the financial year) and conditionally formats rows accordingly
to highlight weekends. Macros post the daily cashup sheet to the Cash
Journal and General journal. I am combining them to operate both from the
Cashup sheet and I need that macro to automatically avoid posting to a row in
the Cash Journal that falls on Sunday. So it must makes a decision on the day
and branch to an alternate macro on Sunday. (Both macros will be the same,
except that €śSunday€ť will jump down 2 more rows (cash register inputs) than
€śWeekday€ť before recreating a range name that acts as a cursor locator.)

Many thanks
Kevryl