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

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
.
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,223,748
Messages
6,174,270
Members
452,553
Latest member
red83

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