+ Reply to Thread
Results 1 to 6 of 6

Macro to loop tasks, double-macros

  1. #1
    Registered User
    Join Date
    05-30-2012
    Location
    Delhi, India
    MS-Off Ver
    Excel 2007
    Posts
    5

    Question Macro to loop tasks, double-macros

    Hi

    I have a wierd problem, may be weird for me but simple for all excel/vba gurus.

    I have 10-15 tabs in a worksheet, I need a loop/macro which leaves the first 3 sheets in the right most side, and from 4th tab onwards, it runs a loop which puts a vlookup formulae in coloum A which have some value in corresponding coloum B. I thought the loop would worked, so I prepared the following code. But this loop is only taking me to previous sheets, but not running the formulae loop inside each worksheet.

    Any help in this would be appreciable.

    Do
    If ActiveSheet.Previous.Select = True Then
    Range("B2").Select
    Do
    If IsEmpty(ActiveCell) = False Then
    ActiveCell.Offset(-1, 0).Select
    ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[2],Responsible!C:C[4],4)"
    ActiveCell.Offset(1, 1).Select
    End If
    Loop Until IsEmpty(ActiveCell) = True
    Cells.EntireColumn.AutoFit
    Range("A1").Select
    ActiveSheet.Next.Select
    End If
    Loop Until ActiveSheet.Previous.Select = False

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,131

    Re: Macro to loop tasks, double-macros

    No idea what your code is meant to do but, if you want loop through the sheets:

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    05-30-2012
    Location
    Delhi, India
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Macro to loop tasks, double-macros

    Hmm...what I want is a code, which run through all the tabs in the workbook, leaving the first 3 tabs in the right most side, and put in a formula in coloum A in all the cells if there is a value in coloum B for the corresponding cells.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,131

    Re: Macro to loop tasks, double-macros

    Just repeating what you said in the OP doesn't make it any clearer. Even if you say it louder

    The position of the worksheets isn't going to change unless you move them.

    And you need to give some explanation of how to recognise the sheets that need the formula inserting

    Perhaps you could upload a sample workbook with the structure, worksheet names and some typical data ... and any macros ... and an explanation of the process.

    From what you've said so far, I don't really understand what you want to achieve.

    Regards, TMS

  5. #5
    Registered User
    Join Date
    05-30-2012
    Location
    Delhi, India
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Macro to loop tasks, double-macros

    Ok I am attaching the actual workbook with few tabs.

    In the attached workbook, I want the code to work on all tabs except the last 3 tabs, i.e (Pivot, Raw Data & Responsible)

    In all the remaining tabs, i.e RBS one card, T & E, Utilities and comm in this case, i want a macro, that select all the reamining worksheets leaving the last 3 tabs as mentioned in the para above, and run a loop in coloum A. And input formulaes in all the cells in coloum A, which have values in coloum B in the corresponding cells. The formula is simple vlook up formulae, which look-up the value in coloum C and give the results from Colouom D of Responsible Tab.

    May be I am clear this time. PLease help me out.
    Attached Files Attached Files

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,131

    Re: Macro to loop tasks, double-macros

    Please Login or Register  to view this content.

    Regards, TMS

+ 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