Row Patterns

MrHuge

Board Regular
Joined
Jun 23, 2005
Messages
219
Hi,
i am trying to create a highlighted row before it is deleted, but if the user cancels from the message box, the formatting needs to stay as it was.

Currently i am using this code
Code:
Sub Macro1()

With Range(Cells(ActiveCell.Row, 2), Cells(ActiveCell.Row, 16))
    .Font.Strikethrough = True
    .Interior.Pattern = xlLightHorizontal
    .Interior.PatternColor = 255
End With

answer = MsgBox("Do you want to delete row " & ActiveCell.Row() & " ?", vbYesNo)

    If answer = vbNo Then
        With Range(Cells(ActiveCell.Row, 2), Cells(ActiveCell.Row, 16))
            .Font.Strikethrough = False
            .Interior.Pattern = xlSolid
            .Interior.PatternColor = xlNone
        End With
    End If
    
End Sub
This works to highlight the row with patterns, but when i answer No, the patterns dissapear, but the original fill color also sets to none.
Is there a way to fix this, or does anyone have a better solution to what im trying to do?
Thanks in advance.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
vbYes will lead into a delete row command, at the moment, i am only after vbNo putting the row formats back to what they were before.
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,543
Members
452,924
Latest member
JackiG

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