+ Reply to Thread
Results 1 to 11 of 11

Improvisation of code to run in all worksheets of a workbook

  1. #1
    Forum Contributor
    Join Date
    11-11-2012
    Location
    Muscat, Oman
    MS-Off Ver
    Office 365
    Posts
    521

    Improvisation of code to run in all worksheets of a workbook

    Dear Experts,
    I have found the below code after lot of search that solves my problem. In its current form it runs on one sheet at a time ( I have 50 plus sheets).
    Help I need it to modify it in such a way that it runs on all the worksheets of the active workbook.
    Please help help/advise…..
    Best Regards/VKS

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Improvisation of code to run in all worksheets of a workbook

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    11-11-2012
    Location
    Muscat, Oman
    MS-Off Ver
    Office 365
    Posts
    521

    Re: Improvisation of code to run in all worksheets of a workbook

    Hello AB,
    Coming here after long time and very happy to see you as Forum Guru……
    Running the code I get this msg “ Run time error 91” Object variable or with block variable not set
    Best Regards/VKS

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Improvisation of code to run in all worksheets of a workbook

    There are a couple of lines missing. Since I do not have any data to test it, you need to tell me in which line do you get the error?

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    11-11-2012
    Location
    Muscat, Oman
    MS-Off Ver
    Office 365
    Posts
    521

    Re: Improvisation of code to run in all worksheets of a workbook

    Hello AB, No more error messages but only sheet one is getting updated with the code below not all
    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Improvisation of code to run in all worksheets of a workbook

    VKS,
    Okay, the best way to test why the code acts on a single sheet is to step over the code using F8 (Using step by step) and see if the code first loops through all sheets. If it does then, which sheet does the code acts on and ignores the rest.
    I suspect the code probably find match only on a single sheet.

  7. #7
    Forum Contributor
    Join Date
    11-11-2012
    Location
    Muscat, Oman
    MS-Off Ver
    Office 365
    Posts
    521

    Re: Improvisation of code to run in all worksheets of a workbook

    Will do and let you know tomorrow. If I face the same issue then I will add a sample file also not 50 but 3 or 4 sheets.
    Though structure of the sheets is same with only difference Analysis 1 and Analysis 2 may appear on different rows in each sheet.
    Thanks for your efforts so far
    Best Regards/VKS

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Improvisation of code to run in all worksheets of a workbook

    VKS,
    The row numbers do not matter as long as you are searching in column A.

  9. #9
    Forum Contributor
    Join Date
    11-11-2012
    Location
    Muscat, Oman
    MS-Off Ver
    Office 365
    Posts
    521

    Re: Improvisation of code to run in all worksheets of a workbook

    Hello AB,
    Both your codes are working great but I cant figure out why they don’t work if I run them from personal macro file but they work fine when pasted in the workbook. Discovered this while making a sample book to share as I couldn’t get them running from a module in personal file since yesterday.
    Best Regards/VKS

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Improvisation of code to run in all worksheets of a workbook

    VKS,
    I am not surprised you can not run the code from personal workbook. Let' say, I have my personal workbook open, but not sheets, how do you loop through sheet's collection? Even if you have sheets, the loop will work with the sheets in the personal workbook, not your actual book.

    Try

    For Each ws In activeWorkbook.worksheets
    and make sure that the cursor is on the active sheet work book you are trying to work on before you run the code.

  11. #11
    Forum Contributor
    Join Date
    11-11-2012
    Location
    Muscat, Oman
    MS-Off Ver
    Office 365
    Posts
    521

    Re: Improvisation of code to run in all worksheets of a workbook

    Thanks AB, You have been a great help and have my star.
    Best Regards/VKS

+ 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] VBA code for Last Row for worksheets in a workbook
    By NYMIC in forum Excel General
    Replies: 0
    Last Post: 05-17-2012, 10:57 AM
  2. Workbook code only for certain worksheets
    By buckhunt122 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-22-2011, 02:16 PM
  3. Code to select all worksheets in a workbook
    By mingali in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-17-2010, 08:56 AM
  4. Code that goes over worksheets in a workbook
    By secondrate in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-16-2010, 02:16 AM
  5. Copy worksheets to new workbook but not vba code
    By mrdata in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-28-2007, 05:35 PM

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