+ Reply to Thread
Results 1 to 13 of 13

Delete blank cells and 2 adjacent cells to the left of blank cells within a worksheet

  1. #1
    Registered User
    Join Date
    03-20-2017
    Location
    Lancashire, England
    MS-Off Ver
    2010
    Posts
    40

    Delete blank cells and 2 adjacent cells to the left of blank cells within a worksheet

    Hi guys,

    Here's hoping somebody can assist in helping me modify an existing code shown below.
    The current code deletes unwanted "." and adjacent cells within a workseet

    The worksheet is created via another programme and the unwanted "." have now been replaced with blank cells.

    I am wondering if there is a way to replace the "." with "blank cells" somehow

    Please Login or Register  to view this content.
    Many thanks for your time
    Andy

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Delete blank cells and 2 adjacent cells to the left of blank cells within a worksheet

    Can you attach a short Excel sample showing your original data frame and the result you want.
    - Battle without fear gives no glory - Just try

  3. #3
    Registered User
    Join Date
    03-20-2017
    Location
    Lancashire, England
    MS-Off Ver
    2010
    Posts
    40

    Re: Delete blank cells and 2 adjacent cells to the left of blank cells within a worksheet

    Hi PCI

    I have tried to attach a copy of what I am trying to achieve, not sure if it has attached or not as I don't see it anywhere. I went to the advanced tab and used the manage attachments to select the one I want it is called Test.xslm

    The file has 3 tabs, Before, After and New

    I have highlighted the rows that I am trying to delete in yellow and they have a full stop in the percentage column. The current macro will delete the relevant rows and the results will be found shown in the After tab. I have also included a New tab that has blank cells instead of the full stops and this is what I am trying to delete

    Thanks Andy
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Delete blank cells and 2 adjacent cells to the left of blank cells within a worksheet

    Could we say hat the first row where to do he job is always 19 ??
    ARe the columns where is the new "empy" cell is always columns "D" & "G"
    A new code must be prepared because empty cells exist every where which makes a difference wih previous "."

  5. #5
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Delete blank cells and 2 adjacent cells to the left of blank cells within a worksheet

    See nex code and adjust Constant o your need
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    03-20-2017
    Location
    Lancashire, England
    MS-Off Ver
    2010
    Posts
    40

    Re: Delete blank cells and 2 adjacent cells to the left of blank cells within a worksheet

    Hi PCI,

    The first row is always 19 but the D & G will continue indefinitely e.g it will continue for every 3rd row every week as additional data is added.

    It will be D, G, J, M, P etc.

    If there is a way to find last row and column and then delete the blank cells and adjacent 2 cells to the left that is what I am looking to do.

    Cheers

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! Try this ‼


    Paste next demonstration to the Sheet6 worksheet module
    as like this in a standard module it works only with the active worksheet :

    PHP Code: 
    Sub Demo1()
          
    Dim C%, Rg As Range
              Application
    .ScreenUpdating False
        
    For 4 To Cells(19Columns.Count).End(xlToLeft).Column Step 3
              Set Rg 
    Cells(Rows.CountC).End(xlUp)
            While 
    Rg.Row 21
               
    If Rg(0).Value "" Then Rg(0, -1).Resize(, 3).Delete xlShiftUp
              Set Rg 
    Rg.End(xlUp)
            
    Wend
        Next
              Set Rg 
    Nothing
              Application
    .ScreenUpdating True
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

  8. #8
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,522

    Re: Hi ! Try this ‼

    Run on the sheet(s) (on a copy of your workbook first) that have a full stop in Column D and Column G that needs deleting
    Please Login or Register  to view this content.
    Last edited by jolivanes; 05-29-2018 at 01:07 AM. Reason: Code tags

  9. #9
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,522

    Re: Hi ! Try this ‼

    Depending on the amount of data you have, this might be faster on a large amount of data.
    If you want to try it, try it on a copy of your original first.
    Please Login or Register  to view this content.
    This is still for the sheet with the periods (full stops).
    If you want it for the sheet with the empty cells, let us know.

  10. #10
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,522

    Re: Delete blank cells and 2 adjacent cells to the left of blank cells within a worksheet

    This should work on the empty cells. (Try on a copy of the original first)
    Please Login or Register  to view this content.

  11. #11
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Delete blank cells and 2 adjacent cells to the left of blank cells within a worksheet

    See next code
    It assumes that the first row is given by cell "Percent"
    and there is 3 columns to delete
    See Const statements for adjustment

    Please Login or Register  to view this content.
    Last edited by PCI; 05-29-2018 at 07:59 AM. Reason: Typo

  12. #12
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Delete blank cells and 2 adjacent cells to the left of blank cells within a worksheet

    Another one more simple for the fun ...!
    It assumes that the header where is the empty cell is "Percent"
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    03-20-2017
    Location
    Lancashire, England
    MS-Off Ver
    2010
    Posts
    40

    Re: Delete blank cells and 2 adjacent cells to the left of blank cells within a worksheet

    Hi Guys,

    Thanks for your help and valued answers, all answers work brilliant. I am spoilt for choice but will use the answers to try and further my excel knowledge.

    Thanks again
    Andy

+ 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. Delete blank cells and move data to left
    By DRS2016 in forum Excel General
    Replies: 10
    Last Post: 04-19-2017, 06:27 PM
  2. Replies: 2
    Last Post: 11-22-2013, 01:07 PM
  3. [SOLVED] Delete special blank cells not recognising blank cells
    By anrichards22 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-04-2013, 03:54 AM
  4. Delete cells if blank, shift left until data found
    By wishkey in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-04-2013, 08:22 PM
  5. Delete adjacent cells when range is blank
    By Buchli in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-29-2013, 05:29 PM
  6. VBA to delete cells that are blank and 0, move to left
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2011, 11:07 AM
  7. delete blank cells and shift data left
    By rhudgins in forum Excel General
    Replies: 7
    Last Post: 07-30-2010, 11:16 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