Remove data which isn't highlighted and shift it all to the left.

chanman

New Member
Joined
Oct 14, 2008
Messages
24
Office Version
  1. 365
Platform
  1. Windows
Hi - Some help required please!

Anyone able to help me with the follow?
Book1
ABCDE
1Sample1Sample2Sample3Sample4Sample5
23A2BG
313211
41A3B3
514231
633213
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A1:E6Cell Value=3textNO


Required output;
Book1
ABCDE
1Sample1Sample2Sample3Sample4Sample5
23
33
433
53
6333
Sheet2


thanks in advance!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Perhaps the thread title gives the clue?
Look at the "required output". Where is the G that magically shows up in post 5 and ends up being the accepted solution?
- I see only 3's in the "required output".
- The cf formula is only for 3. I'd say that an sample of what you want trumps anything you might write that describes it. You, sir, are clairvoyant for sure! :)
 
Upvote 0
Thanks for the feedback chanman :) (y)
Although you have a solution, I always feel compelled to correct any previously shared code now new conditions are known. So just for my own benefit:
VBA Code:
Option Explicit
Sub chanman_V3()
    Application.ScreenUpdating = False
    Dim ws As Worksheet
    Set ws = Worksheets("Sheet1")       '<-- *** Change to actual sheet name ***
    Dim r As Range, c As Range
    For Each c In ws.Range("A2", ws.Cells(Rows.Count, "E").End(xlUp))
        If c.DisplayFormat.Interior.Color <> vbYellow Then
            If r Is Nothing Then Set r = c Else Set r = Union(r, c)
        End If
    Next c
    r.Delete shift:=xlToLeft
    Application.ScreenUpdating = True
End Sub
@kevin9999 appreciate the effort so I had to give a test of course. If worked, but only partially. It only performed the deletion on row 2..
 
Upvote 0
No worries, looks like you got a good solution from Peter anyway :) (y)
 
Upvote 0
I don't understand how that can be when in the first post your cf condition is cell equals 3. Oh well.
@Micron like I said in the my post yesterday, I over simplified my conditional formatting when creating the sample data. Sorry again!
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,911
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top