+ Reply to Thread
Results 1 to 8 of 8

Help with Code to delete selected ran=ge based on Value of the cell

  1. #1
    Forum Contributor
    Join Date
    06-17-2014
    Location
    london
    MS-Off Ver
    365
    Posts
    398

    Help with Code to delete selected ran=ge based on Value of the cell

    hi Everyone

    I appreciate any help as to what I need to achieve as my VBA knowledge ois not as strong.

    I have attached a very simple spread sheet to demonstrate what I need to do.

    In the sample sheet what I need is for the code to do the following:
    Look at Col G: and if cell =#N/A then select range d:G and delete by shifting cells up. i.e. G4 = #N/A then it selects D4:G4 and delete the contents and shifts cells up. then it looks at the next row and does the same. If G is not #N/A the it will leave it as it is.

    In my actual sheet I have over 3000 rows and doing this manually will take days.
    It will be nice for the code to start from the a2:g2 and does the above procedure every time G? (?=row reference)=#N/A until G2<>#N/A and then move until G hits another #N/A do the same until g<>#N/A and so on until the last row in the sheet.

    Any help is appreciate it.

    I hope I make sense.
    Attached Files Attached Files

  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
    44,426

    Re: Help with Code to delete selected ran=ge based on Value of the cell

    I am bemused as to why you would want to:
    delete the contents and shifts cells up
    That will misalign all subsequent rows of data. Is that really what you want? Easy enough but, I suspect, bad idea.


    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
    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
    44,426

    Re: Help with Code to delete selected ran=ge based on Value of the cell

    Without moving data up ...

    Please Login or Register  to view this content.

    Regards, TMS

  4. #4
    Forum Contributor
    Join Date
    06-17-2014
    Location
    london
    MS-Off Ver
    365
    Posts
    398

    Re: Help with Code to delete selected ran=ge based on Value of the cell

    Thankd for this. But I do need to move the data up, will it be possible to have a code for this too

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Help with Code to delete selected ran=ge based on Value of the cell

    Maybe:

    Please Login or Register  to view this content.

  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
    44,426

    Re: Help with Code to delete selected ran=ge based on Value of the cell

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    06-17-2014
    Location
    london
    MS-Off Ver
    365
    Posts
    398

    Re: Help with Code to delete selected ran=ge based on Value of the cell

    Thank you so much for this. I really appreciate your help.

  8. #8
    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
    44,426

    Re: Help with Code to delete selected ran=ge based on Value of the cell

    You're welcome. Thanks for the rep.

+ 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] Code will not delete selected item
    By zplugger in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-08-2015, 09:27 AM
  2. [SOLVED] Don't run code based on selected cell
    By FallingDown in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-21-2014, 07:12 AM
  3. [SOLVED] Highlight cell based on selected cell - Code required
    By SharpL in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-24-2014, 09:48 AM
  4. [SOLVED] VB code to delete value in a cell based on finding another Value
    By psoft in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-28-2014, 09:51 AM
  5. VBA code to find and delete cell contents based on userform combobox selections
    By anfdrew in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-06-2013, 04:13 PM
  6. Delete Button code to Delete Selected Entry
    By macky1730 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-14-2013, 02:30 AM
  7. VBA code to delete rows in a selected range.
    By LD2020 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-23-2009, 02:06 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