+ Reply to Thread
Results 1 to 6 of 6

Help in editing my macro to Loop through All Worksheets in my sample workbook

  1. #1
    Registered User
    Join Date
    06-23-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    16

    Help in editing my macro to Loop through All Worksheets in my sample workbook

    I need some help in editing my macro so that it runs on all the sheets in the workbook.
    The problem I am facing is that after running the few steps ... currently my macro has a loop involved i.e. it needs to stop if A2 is empty, While if not it needs to continue.

    So can someone help me with editing my macro so that it can run correctly on all the sheet ?
    I.e. Stop if the A2 is empty & move on to the next sheet to run the macro from start . If the A2 has some data then run the remaining macro & then move onto the next sheet to run the macro on that till the time all the sheets in the excel are covered.

    Attached is my macro & the sample File on which I need to run the macro.

    I'll be really glad if someone could help me with edit my macro to run as per my requirements.

    Thanks,
    TPM
    Attached Files Attached Files

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Help in editing my macro to Loop through All Worksheets in my sample workbook

    one way

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Registered User
    Join Date
    06-23-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    16

    Re: Help in editing my macro to Loop through All Worksheets in my sample workbook

    Thanks Mike, And sorry for not being clear earlier with my query

    My problem is that there are few thing already in my macro which runs (multiple steps) & then the criteria for A2 cell comes.

    Can you please edit my existing macro (attached) & run it on the excel (sample attached) to see what I am talking about.

    Thanks,
    TPM

  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Help in editing my macro to Loop through All Worksheets in my sample workbook

    Not sure is this what your wanting? Just used your code and added a worksheet loop

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-23-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    16

    Re: Help in editing my macro to Loop through All Worksheets in my sample workbook

    A part of my issue is resolved with the code you modified. But one major problem in my code is still there.

    What should be rectified in the code that the macro runs into the next sheet then just exit (as in the below) ?


    'Activate Hyperlink

    Range("D2").Select
    Selection.Copy
    Range(Selection, Selection.End(xlDown)).Select
    For Each xCell In Selection
    ActiveSheet.Hyperlinks.Add Anchor:=xCell, Address:=xCell.Formula
    If ActiveSheet.Range("D3").Value = "" Then Exit Sub
    Next xCell


    Thanks,
    TPM

  6. #6
    Registered User
    Join Date
    06-23-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    16

    Re: Help in editing my macro to Loop through All Worksheets in my sample workbook

    A part of my issue is resolved with the code you modified. But one major problem in my code is still there.

    What should be rectified in the code that the macro runs into the next sheet then just exit (as in the below) ?


    'Activate Hyperlink

    Range("D2").Select
    Selection.Copy
    Range(Selection, Selection.End(xlDown)).Select
    For Each xCell In Selection
    ActiveSheet.Hyperlinks.Add Anchor:=xCell, Address:=xCell.Formula
    If ActiveSheet.Range("D3").Value = "" Then Exit Sub
    Next xCell


    Thanks,
    TPM

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] help in editing my macro to close the loop
    By tmaster81 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-18-2014, 10:59 AM
  2. Loop Through Worksheets in a Workbook
    By Maj382 in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 07-05-2013, 12:02 PM
  3. code to loop until workbook is available for editing. is it possible?
    By Mstant in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-26-2012, 06:14 PM
  4. [SOLVED] Macro to loop through all worksheets in workbook not working...
    By cariwest in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 09-25-2012, 10:45 AM
  5. Need to loop code for certain worksheets in workbook
    By longbow007 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-28-2010, 08:00 AM

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