VBA Cut and Paste keeping same number of rows

Manda86

New Member
Joined
Feb 21, 2012
Messages
1
Hey,
So I am relatively new to VBA and am having some issues. What I am currently trying to do is to remove or clear a row that has been formatted with strikethrough. My list must remain at 1000 rows with the same formatting (color, size etc). One way I have been going about this is clearing the contents of the row, then cutting and pasting at the end of how ever long my current list is (somewhere within 1000). This is the code I am using so far:

Note: As I am implementing this over several worksheets I am stepping through all the tabs and this is what checkTab is. And I am starting at 18 as that is where my data starts (all headings above).

' Finding the last row with entered data
lastLine = Sheets(checkTab).Range("G1000").End(xlUp).Row

For counter2 = lastLine To 18 Step -1
If Sheets(checkTab).Rows(counter2).Font.Strikethrough = True Then

'I only want to clear a certain range in the row
Sheets(checkTab).Range("A" & counter2, "AT" & counter2).ClearContents

Sheets(checkTab).Rows(counter2).Select
Selection.Cut
Selection.Rows(lastLine+1).Select
Selection.Insert Shift:=xlDown
End If
Next

For some reason which I cannot understand...I am getting fully blank lines with the formatting removed. I have tried recording a macro cutting and copying to see what it did but that wasn't much help.

Any help would be greatly appreciated
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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