+ Reply to Thread
Results 1 to 13 of 13

Macro for repeat functions with if condition

  1. #1
    Registered User
    Join Date
    10-19-2012
    Location
    Ahmedabad, India
    MS-Off Ver
    Excel 2003
    Posts
    6

    Question Macro for repeat functions with if condition

    Hi...

    Can anyone help me to prepare a macro for repeat function till the reference column has a data.

    To illustrate, if a cell of (column-1 of worksheet-1) has a number, the number needs to be referred in worksheet-2 for analysis and the result shall be copied back in a column-2 assigned in worksheet-1. This function shall be repeated till column-1 has data cells.

    I am looking for a macro which can repeat the said function till it finds a data in column-1.

    Looking forward for a solution as soon as possible.

    Thanks

    Kanagaraj

  2. #2
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Macro for repeat functions with if condition

    You have a Loop option or For Each Cell in a range option...
    For better understanding of your problem you should upload a sample workbook that contains the current situatius and the outcome. It's much easier to make a code that way

  3. #3
    Registered User
    Join Date
    10-19-2012
    Location
    Ahmedabad, India
    MS-Off Ver
    Excel 2003
    Posts
    6

    Exclamation Re: Macro for repeat functions with if condition

    mkanagaraj.xlsx

    As desired, find attached sample file, wherein sheet-1 has reference cells in yellow colour and result cells in green colour.Hope, this would provide much clarity on my query.

    Please provide a solution to it.

    Thanks

    Kanagaraj

  4. #4
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Macro for repeat functions with if condition

    Here you go
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    10-19-2012
    Location
    Ahmedabad, India
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Macro for repeat functions with if condition

    Thanks for your guidance

    May you help me to update the macro if i add another criteria, which is marked in blue colour to analyse.

    This has 2 criteria as reference, which shall repeat. The file is attached

    I tried to revise the macro, but i could not get. mkanagaraj - Calculate (2).xlsm

    Please help me.

    Thanks

    Kanagaraj

  6. #6
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Macro for repeat functions with if condition

    You want the macro to only calculate the results of the cells in column A if they are marked blue? Or what?

  7. #7
    Registered User
    Join Date
    10-19-2012
    Location
    Ahmedabad, India
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Macro for repeat functions with if condition

    No.

    Column A (Blue) and Column B (Yellow) of Sheet1 are to be referred in C2 and C4 of Sheet2 respectively to get the result in C6 and transfer the same to Column C (Green) of Sheet1. The function shall be repeated for all data cells.

    Column A and Column B are reference data
    and Column C is the result.

    Hope, it is clear. Plz revert back in case of further clarification.

    Thanks

    Kanagaraj

  8. #8
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Macro for repeat functions with if condition

    No I think I got it now.
    I'll get back to you on Monday morning

  9. #9
    Registered User
    Join Date
    10-19-2012
    Location
    Ahmedabad, India
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Macro for repeat functions with if condition

    Hi Stojko

    Looking forward for your suggestion.

    Thanks

    Kanagaraj

  10. #10
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Macro for repeat functions with if condition

    Yes hi. I was wondering. Why do you need the results copyed from one sheet to another and then the result back to sheet 1?
    Why can't you just insert the formula in Column C and you'll have the calculated results withouth copying and withouth using a macro...

  11. #11
    Registered User
    Join Date
    10-19-2012
    Location
    Ahmedabad, India
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Macro for repeat functions with if condition

    You are right. But, I have some similar analysis, which is derived from cluster of formulas with number of other references and therefore, i can't insert formula in column C. The result will be taken from another model all together. Therefore, this macro would help me to use for such analysis.

  12. #12
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Macro for repeat functions with if condition

    So once again
    If column A is blue and column B is yellow calculate the result on sheet 2 and copy it in column C and color the result green?

  13. #13
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Macro for repeat functions with if condition

    I've changed your blue color so I don't have to set the shading and so on...
    But here you go.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1