vba delete red column in entireworkbook at print area

hematinsite

New Member
Joined
Nov 3, 2020
Messages
14
Office Version
  1. 2019
Platform
  1. Windows
hi dear
in excel 2019 , Is it possible to have a macro that in my entire workbook in any cell in print area , if red color font used , then delete entire columns . i have not use conditional formating font .
please help me .
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
.
VBA Code:
Option Explicit

Sub test()

    Dim rng As Range, cell As Range
    Dim ws As Worksheet

    With ThisWorkbook

        For Each ws In .Worksheets
            With ws
                Set rng = .UsedRange

                For Each cell In rng
                    If cell.Font.Color = vbRed Then
                        cell.EntireColumn.Delete
                    End If
                Next cell
            End With

        Next ws

    End With

End Sub
 
Upvote 0
hi dear
thx but show error after run in last line end with. this error is here :

compile error
expected end with
 
Upvote 0
That is a warning that an END WITH statement does not exist in the code where it should be.

After looking at the posted code I do not see where that error exists.

Please check your copy / paste of the code.
 
Upvote 0
.
Your original request does not match your last description or the workbook.

You stated "delete column". What you are really wanting is DELETE ROW.

So .. using your example workbook ... are you wanting the row DELETED ? Or are you wanting the data in those cells erased, resulting in blank cells ?
 
Upvote 0
99% solved , after i deleted this line , then perfect worked
'If cell.Value = strToFind Then
'cell.Interior.Color = RGB(255, 0, 0)

whats do this line ?

and for continue , if i want 1-convert formula to their value in cell with green font and after convert , then 2-change green font to black font in their cell , how can with vba ?
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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