Results 1 to 3 of 3

Delete and shift remaining cells to the top.

Threaded View

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,062

    Delete and shift remaining cells to the top.

    I hate it when something simple becomes hard.

    See the attachment. All I want to do is delete all of the cells filled with only "d", and shift the remaining cells to the top. This is just a sample; my data set actually has about 250 columns of 12K rows each.

    I can do it fine manually, but only for a small subset. The larger the data set, the slower Excel operates, so I'd like to do it via VBA. The process I want to replicate in my macro is done like this: in my Usedrange, do a Find, "d", in "Values". Select all found. Delete. I thought I'd record the process to get the basic code for my macro. The below macro is what came out of the recording.
    Sub Macro5()
    '
    ' Macro5 Macro
    '
    
    '
        Range("A1:R19").Select
        Range("R19").Activate
        Range("O26").Select
    End Sub
    So I tried to do it on my won. The macro below is my attempt. For some reason, it only appears to work for one row at a time, and I don't know why. So, any help on this would be highly appreciated.
    Sub FirsttryDel_d()
        Dim rng As Range
    
        Application.ScreenUpdating = False
        For Each rng In ActiveSheet.UsedRange
            If rng.Value = "d" Then
            
            rng.Delete Shift:=xlUp
            End If
        Next rng
    
        Application.ScreenUpdating = True
     
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Delete all cells in each row except the last used cell then shift left all remaining data
    By dave033 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-16-2014, 09:33 AM
  2. Macro to Remove Cells = 0 and Shift Remaining Cells on Row Left w/ One Condition
    By Mark V. in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-07-2013, 12:45 PM
  3. [SOLVED] Find cells which contain specific word, delete cells and shift left.
    By BPSJACK in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-24-2012, 07:00 AM
  4. Delete empty cells and shift remaining left
    By kiboodez in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-25-2010, 02:17 PM
  5. Delete cells and shift up
    By smiso24 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-07-2009, 03:51 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