PDA

View Full Version : Solved: Deleting part of a merged cell



a20z07
06-28-2011, 07:57 AM
How do I only delete a single row within a merged cell in a macro? I need to do this because I have a chart that has some parts merged, and whenever I run my code, the entire chart is deleted instead of only the part I want.

Sheets("Sheet2").Select

lastRow = ActiveSheet.UsedRange.Rows(ActiveSheet.UsedRange.Rows.Count).row

For row = 33 To lastRow
If Cells(row, 25) = "1" And Cells(row, 15) = "0" Then
Rows(row & ":" & row).Select
Selection.Delete Shift:=xlUp
row = row - 1
End If
Next row


Also, if I right click the row number in the Excel and click delete, only that row will be removed. I recorded these actions in a macro, but the macro deletes the entire merged cell... Any ideas?

Thanks!

p45cal
06-28-2011, 10:45 AM
untested, try changing the two lines:

Rows(row & ":" & row).Select
Selection.Delete Shift:=xlUp

to just:

Rows(row).Delete

a20z07
06-29-2011, 06:25 AM
Thanks, that worked perfectly.