Code to cut and paste row in red text

charllie

Well-known Member
Joined
Apr 6, 2005
Messages
986
Hi Folks,

If possible i need a code to do the following when a macro button is pressed.

  • Check column A in sheet1 and if the text in any row is in red text then cut and paste that whole row to the next empty row in sheet 2.

    In other words remove all rows in red text from shett 1 to sheet 2.
I would really appreciate anyones help.

Thanks
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

charllie

Well-known Member
Joined
Apr 6, 2005
Messages
986
Hi Boller,

Thanks for your response.

No, the text is change to red manually using the font colour tool bar etc. Conditional formatting is not used on sheet 1 or sheet 2.

Black and red text are the only two colours used on sheet 1.

Hope that helps.

Thanks
 
Upvote 0

Boller

Banned
Joined
Apr 11, 2006
Messages
2,328
Code:
ActiveWorkbook.Names.Add Name:="col", RefersToR1C1:="=GET.CELL(24,INDIRECT(""rc[1]"",0))"
Columns(1).Insert
With Range([A1], [B65536].End(xlUp)(1, 0))
    .FormulaR1C1 = "=IF(col,""d"",1)"
    .EntireRow.Sort Key1:=[A1], Order1:=xlAscending, Header:=xlNo
    On Error Resume Next
    .SpecialCells(xlCellTypeFormulas, 2).Offset(0, 1).Resize(, 255).Cut _
        Sheets("Sheet2").[A65536].End(xlUp)(2)
    On Error GoTo 0
    .EntireColumn.Delete
End With
ActiveWorkbook.Names("col").Delete
 
Upvote 0

charllie

Well-known Member
Joined
Apr 6, 2005
Messages
986
Hi Boller,

Thank you very much i really appreciate that. it does the job brilliantly.

The only error i got was if the macro was used by accident when there was no red text on page i got a default message.

Is there a way around that?

Thanks
 
Upvote 0

Boller

Banned
Joined
Apr 11, 2006
Messages
2,328
Yes, I amended the code to handle that - must have amended it after you copied the code but before you responded.
 
Upvote 0

Forum statistics

Threads
1,191,354
Messages
5,986,173
Members
440,008
Latest member
Cmbuck

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
Top