Code in a macro to branch to another macro?

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

0
Utf
4/24/2010 1:50:01 PM
excel.programming 6508 articles. 2 followers. Follow

2 Replies
1375 Views

Similar Articles

[PageSpeed] 26

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
> 
0
Utf
4/24/2010 2:26:01 PM
Hi JL, thanks for such a fast response.

Yes & No - no code for the Sunday decision but the very lengthy macros to be 
combined have been running smoothly every day for about 6 years. 

The names: just used Saturday and Sunday for ease of explanation. I shall 
take your advice on that. I'm surprised that "ProcessSundays" doesn't need to 
be inside quotes or brackets.

One problem remains: "Range("D5")" in your code is absolute, and it needs to 
be relative to travel down the sheet. The cursor will be in column E (at 
rangename "CJreturn" at the point when it refers to the contents of Column C. 
I could use the same name/delete/rename routine that I use for "CJreturn" to 
advance the cursor begin point, and address the rangename,  but there's 
probably a tidier way. Will that work, just substituting (say) the rangename 
"daycheck" for "D5" in the code you have given? I reckon it should. 

Well, its 1.00am Sunday here in Tasmania and I gotta go home! I presume its 
late Saturday afternoon where you are so have a great evening!

Thanks again.

"JLatham" wrote:

> 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
> > 
0
Utf
4/24/2010 3:04:01 PM
Reply:

Similar Artilces:

Integrate Paycodes, benefit codes and deduction codes
Has anyone used integration manager to update new pay rates, deduction amounts and benefit amounts for employees? At the beginning of each year, our company gives pay increases and we need to update the pay codes, deduction codes and benefit codes for 40 employees, which we get the information from a spreadsheet. I thought that maybe I could use integration manager to update the pay, benefit and deduction codes instead of going into each employee's card, which is time consuming. Thanks, Laura Integration Manager will allow you to do this. Use the Payroll Master Destination. one ...

zip codes don't merge #2
I am trying to mail merge w/ Word 2000 the names and addresses in my worksheet. When I get to the part to choose the format for the mailing labels, I choose F1, F2, etc. to F6 (which is the zip code column). A few do get there, but the vast majority stop at the state, leaving off the entire zip code. I have gone to menu/format and selected text in the number tab. I have gone to format/cells and chosen special/zip code in the number tab. I've read Excel for Dummies. Please help me. TIA bb ...

fields taking data from one record to another
I have a coworker who is experiencing problems with a database that she created. The main table in this database lists client information, including first name, last name, address, etc. Within the past 1-2 weeks, they've noticed problems where people's information is incorrect when they pull records back up. For example a record this morning came up with a man's name being switched from Lawrence to Elizabeth... In every case, the field now contains the same information that is in the record before it.. so for example in this case the record before the one for Lawrence was for a wom...

concatenating two vendor codes
My company recently changed the vendor codes and now I end up with two separate sets of data for each vendor. Obviously I could just leave the vendor code field out. I don't want to do that so what I need to do is concatenate the two codes. Example Vendor Code Vendor Name 123 Joe's Supplies ABC Joe's Supplies what I need is this Vendor Code Vendor Name 123/ABC Joe's Supplies any ideas? Rather than create a new record for each vendor, add another field to the table -- call it NewVendorCode -- and put th...

Counting Cells in a column depending on another column but excluding duplicates
Hello, I would like to count the total in a column depending on another column, but exclude duplicates. I my case I would like to know how many employees (column A) have taken a course in 2010 (column B). Column A has duplicate names. Column B has 2009 and 2010 as the year the course was taken. I want to count 2009 and 2010 separately. I named the range of column A course_attendees and column B course_taken Name Course Year Wilbert Bugay 2009 Wilbert Bugay 2009 Zahid Gul 2009 Zin Minn Lwin 2009 Zin Minn Lwin ...

Macro help #10
Hi! I have a table with customers that have made multiple purchases of different products. I would like to have a macro that creates a purchase number based on the number of times they have purchased individual items. For example, the first time they purchase Product A a 1 would go in this new field, the second time they purchase ProductA a 2 would go in this field. I understand this would work through a date loop but I am lost as to how to accomplish this. I am not really familiar with writing macro's! Another key thing is that in order for it to be a purchase it must not have been a sam...

16 bit code
Hello, I have a 16 bit code to maintain. (It is too complex to copile it to 32 bit) so all we are doing is support. Now they want to add a small feature, where I need to copy long file names in the project. I know we can not do long file name copies in vc++ (1.52). So I wrote a program in VC++(6.0) which does directory copy. My questions are 1. How can I call a 32 bit exe (I guess WinExec should work)? 2. How can I make the 16 bit to wait till the 32 bit code completes? 3. Is there any other better way to do this? (other than converting to 32 bit) Thanks. I actually do this in an old 16-bi...

Can MS EXCEL remove duplicates and separate by color coded items ?
Can MS EXCEL remove duplicates and separate by color coded items ? I am NOT technical and have just started using MS EXCEL. Can anyone PLEASE HELP me: 1. How can I automatically remove duplicates using EXCEL ? ie the same info input more than once on different lines. Can EXCEL do this ? 2, I have color coded the text in the certain lines in terms of priority. can Excel rearrange the data by color ? If yes, How do I do it ? I think I have EXCEL '97 Thanks for your help in advance. Hi 1. You can extract the unique items to a new list using menu Data > Filter > Advanced fil...

area codes is auto filling my own 9 digit ph# vs just area code
When I enter a phone number for a contact it autofills with my personal area code and phone number instead of just the area code. How to I change this to just autofil the area code? I am using Outlook 2007 on an ACER laptop. Make sure you have your area code entered correctly in "Dialing Properties". "Computer Dummy" wrote: > When I enter a phone number for a contact it autofills with my personal area > code and phone number instead of just the area code. How to I change this to > just autofil the area code? I am using Outlook 2007 on an ACER ...

Define Name use in Macros
I am not sure how or if you can use the Define Name function in a worksheet to assign a value in an Macro. I am using the command below to assign a value in the worksheet in the macro. However the user might make changes to the worksheet that makes this method invalid. If I use the Define Name function in excel and create a Name can I then us it to assign a value? Set Total_Assets = Sheets("Balance Sheet").Range("H55") You should definitely assign a name (Ctrl-F3) to this cell and all ranges your macros used, in case you or your users insert rows, etc. Set Total_...

VBA Code for Pasting Sheets
I would like a spreadhseet that pastes the contents of one sheet into another sheet. I like like to do this for 7 different sheets For example: I would like paste the contents form sheet titled "sheet1" into a sheet titled "data1". Continue to process for pasting "sheet2" into "data2" and "sheet3" into "data3" all way until "sheet7" and "data7". thanks, Curt Subject: Automated Copy Paste Subject: Copy/Paste Import/Export Data VBA Code On Apr 27, 10:49=A0am, Curt <C...@discussions.mi...

MC/VISA joint code
Isn't there any way to combine the blocks (4* & 5*) for MC/VISA credit cards? It's a pain to have them separate because my bank posts them together. It is the same company afterall. It would save me a lot of time adding separate entries together to reconcile the statement! I do not know of a way to do what you are asking, but I have found that using the # symbol as follows works better than using the * symbol: 4############### 5############### If you use the * symbol it is a wild card with no determined length. The # symbol requires that the characters after the first d...

Open a form using a comand button on another form
By using a command button on a certain form I am oppenig an other form at a cetain record by using some criteria. I am using the command button wizard to do that. When the form oppens however, I want to be able to move to other records of the form record source. Is there an easy way to do that? Thanks in advance Michalis Instead of passing the criteria in the WhereCondition, pass it in OpenArgs instead. Then use the form's Load event to FindFirst in the RecordsetClone, and set the Bookmark. -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http:/...

Typing an adress in a form and verify if it exist in another form
Hi, One form for user without permit. One form for user with permit. If a user without permit takes a permit, a click on a button transfer the user in the form for user with permit and destroy the user without permit. But ! Sometimes a user with permit is created, and we realize to late that the same user already existed in the form for user without permit. I would like, after finishing to type the user address, using the form for user with permit, to verify if the address already exist in the table for user without permit. In both form, the address is compose of three fields : number, apa...

Money 2004 - Experian Offer
I just loaded Money 2004 Deluxe and converted my 2003 files with no problem. I decided to give the free year of credit monitoring from Experian a try but after filling everything out I get an error that the provided code has expired. I neither had nor provided any code for this offer, I only used the link from Money 2004. Now Experian was more than willing to set up a $79 account if I wanted to proceed. Any solution out there? I have the same problem... I am looking for a FREE way to contact Microsoft about this problem. >-----Original Message----- >I just loaded Money 2004 ...

MACRO QUESTION #17
I have a spreadsheet that has 5 columns -- Date, Buyer Code, Value of Purchase, Seller Code, Value of Sale. Each row is a buy/sell transaction between a buyer and a seller, so (Value of Sale) = -(Value of Purchase). The buyers and sellers are a closed group, so that the group of Buyer codes is the same as the group of Seller codes. There is a macro which creates a worksheet called Buyers (deleting any existing worksheet of that name) containing subtotals of the Value of Purchase column for each Buyer Code. Similarly, there is another macro which creates a worksheet called Sellers containing...

Access combo box control by another data field
Hi, I use a combo box in a form with look-up from a table for selecting data. Easy enough. But, I want to only see a selection of the data in the table, depending on a value in another field in the form. I the combo box table I have ID, data1, and data. data1 is the one that shall be equal to the other field. 1, 1, text1 2, 1, text2 3, 2, texta 4, 2, textb 5, 2, textc etc. I have tried using the standard query that comes with the combo box, and then adding a WHERE statement testing against the data fiel in the form, but it does not work. Any suggestions anyone? Check this link on &...

Analytical Accounting
Hi, One of my Client's is considering to go down AA path with approx 300,000 AA dimension codes. I would like to hear whether such data set is manageable from Query wizard etc. appreciate your thoughts. Good Morning PR, I found that the issue isn't the number of AA Trx Dim Codes it is the size of the AAG30000 and AAG40000 tables the more entries the longer it takes to product the report. I had one client that started having a cached SSRS report with AA information as a management level report and a different SSRS report with a more restrictive dataset for reporting ...

Change code with code?
Hi All..... I've got 31 Excel .xlsm files to modify the "Change Event" macro in. Is it possible to open and perform this with code, or must I do each one by hand? TIA Vaya con Dios, Chuck, CABGx3 If it is the same change in each sheet, it would probably be just as easy to go into the VBE, double click on the first sheet, make the correction, then copy that correction and double click the second sheet, delete and paste. Repeat the process 30 times. Takes less time than writing the code to do it. "CLR" <CLR@discussions.microsoft.com> wr...

Macro
Hello, Can I launch Word from within an Excel macro? If so, how? Bill Bill a �crit : > Hello, > > Can I launch Word from within an Excel macro? If so, how? > > Bill > > Hi Bill, Something like : Sub test() Set ww = CreateObject("word.application") ww.Visible = True End Sub HTH FxM Or using early binding (You will need to manually set a reference to the Word Object Library through Tools...>References... in the VBE) Sub RunWord() Dim wd As Word.Application Set wd = New Word.Application wd.Visible = True End Sub -- HTH Nick Hodge Microso...

Access 2003
I have a form that goes to a subform for searching. It works perfectly on my computer; however, when another user opens it and attempts to perform a search, they receive the Error Code 2455 message. When I debug, it gets stuck on "Me.book_subform.Form.Filter = strWhereSearch" and says that book_subform cannot be found. It isn't a rights issue, it isn't a mapping issue. What am I missing? check your naming. This is an issue that often confused. In this syntax: Me.book_subform.Form.Filter > = strWhereSearch book_subform is the name of the subform control on the main ...

Problem in excel VB using macros
I am new to this excel VB Macros. I came across the excel sheet with macros which extracts 10 heights from a text files stored in some subfolder in server. For eg: Product A has ten heights in ten columns in a row ProductB has ten heights in ten columns in second row..Likewise around 100 products are there..But sometimes all these ten heights are not there.. For eg: Product A has only 7 heights the rest 3 columns are empty For eg:Product b has only 3 heights the rest 7 columns are empty.. So i want to take the last height available from each product row . After that i want to calculate the...

Recording macros with relative row and column relationships
I am trying to copy information in Excel 2003 from one row to a new row on separate worksheets, using a macro. However, the macro records actual rows and columns (even though the "$" is not present), which I have verified by running the macro with a newly created row. (It still copies the previous row to the other worksheets and not the new row.) How do I record a macro with relative rows/columns, so that I can copy the data from each newly created row on the first worksheet to the remaining 14 worksheets in the workbook? (Please note that I am not copying all the data fro...

Write a code by code
How can I write a code from procedure to some Workbook's ThisWorkbook? With procedure1 a make Workbook with a table. I need to write Auto_Close procedure to ThisWorkbook which makes some controls before I close it. Is it possible? <jenista.j@discussions.microsoft.com> wrote in message news:0be501c52fab$ba0b6830$a601280a@phx.gbl... > How can I write a code from procedure to some Workbook's > ThisWorkbook? With procedure1 a make Workbook with a table. > I need to write Auto_Close procedure to ThisWorkbook which > makes some controls before I close it. Is it possible? ...

Coding Duplicate Records
How can I code that a record is to be "K" kept or "D" deleted when compared to its next row? Example: A sorted file by Address BEFORE LastName Address Sales Date Keep/Delete 1. WASSEM 0N642 TITUS PL 67,500 6/25/2001 2. HART 0N655 E WEAVER CIR 70,000 3/19/2001 3. HART 0N655 E WEAVER CIR 40,000 3/19/2001 4. HART 0N655 WEAVER CIRCLE 33,700 6/19/1998 5. POYTH 0N662 W WEAVER CIR 294,690 6/21/2000 6. BLAND 0N670 GREEN PL ...