+ Reply to Thread
Results 1 to 7 of 7

Code that finds and deletes names from current sheet to all worksheets in workbook

  1. #1
    Registered User
    Join Date
    06-19-2013
    Location
    Chicago, United States of America
    MS-Off Ver
    Excel 2010
    Posts
    35

    Code that finds and deletes names from current sheet to all worksheets in workbook

    Hello!

    Currently I have code that searches for an individual's last name in column A , finds the row, and deletes the row. This works perfectly on the active sheet I am on. (Inspiration from http://tinyurl.com/m5mbanb)

    In my workbook, I have several worksheets corresponding to each week of the year. I hope to have the code I have iterate through each worksheet and delete the same name from Column A in each worksheet. The catch is that the name will not be in the same row on each sheet. Thus, the string needs to be found again on each sheet.

    I have attempted to use a For each statement; however, that yields an error. Additionally I have attempted to set up array variables where the name location can be saved but I have been unsuccessful
    Please Login or Register  to view this content.


    Code:
    Please Login or Register  to view this content.

    When I have the For each loop in, I receive a "Delete method of range class failed" error, and the code that is highlighted is

    Please Login or Register  to view this content.
    If anyone has any thoughts, I would really appreciate it.

    Best,

    Grazian2

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

    Re: Code that finds and deletes names from current sheet to all worksheets in workbook

    Untested

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-19-2013
    Location
    Chicago, United States of America
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Code that finds and deletes names from current sheet to all worksheets in workbook

    AB33,

    Thank you for your reply. Unfortunately, the code you posted was the code I mentioned I tried. When I run the code with a For each loop I get a When I have the For each loop in, I receive a "Delete method of range class failed" error, and the code that is highlighted is

    Please Login or Register  to view this content.

    It would be great if you have any more input

  4. #4
    Registered User
    Join Date
    06-19-2013
    Location
    Chicago, United States of America
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Code that finds and deletes names from current sheet to all worksheets in workbook

    AB33,

    Thank you for your reply. Unfortunately, the code you posted was the code I mentioned I tried. When I run the code with a For each loop I get a When I have the For each loop in, I receive a "Delete method of range class failed" error, and the code that is highlighted is

    Please Login or Register  to view this content.

  5. #5
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Code that finds and deletes names from current sheet to all worksheets in workbook

    Try this modification to you "For Each" loop and see if this works better.

    Please Login or Register  to view this content.
    Alf

  6. #6
    Registered User
    Join Date
    06-19-2013
    Location
    Chicago, United States of America
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Code that finds and deletes names from current sheet to all worksheets in workbook

    Alf,

    Thank you for the reply!

    Unfortunately, I still receive the same error.

    I found that if I use
    Please Login or Register  to view this content.
    instead of
    Please Login or Register  to view this content.
    I did not get an error.

    Then, I sort each worksheet by column A and the row that had its contents cleared is moved to the bottom.

    Thank you all for your help!

    Grazian2

  7. #7
    Forum Contributor
    Join Date
    09-23-2007
    Location
    Melbourne, Australia
    Posts
    176

    Re: Code that finds and deletes names from current sheet to all worksheets in workbook

    Attempted to answer in error

+ 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. Replies: 2
    Last Post: 07-31-2013, 03:21 PM
  2. VBA code to copy data from specific worksheets from current workbook to a new one
    By Uday2013 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-01-2013, 12:15 PM
  3. [SOLVED] Edit the code so that it loops through all worksheets and deletes column with "grand" text
    By rocksan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-13-2012, 02:58 AM
  4. Export worksheets from a workbook to the current workbook location path
    By legendkiller420 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-22-2010, 04:08 AM
  5. Help with code that finds a sheet's name
    By KimberlyC in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-10-2005, 06:05 PM

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