Code Error will not find first empty cell in column

tnt6869

New Member
Joined
Sep 28, 2011
Messages
17
Here is some code that I have been using sucsessfully to add formatting to the next 10 rows at the end of the current sheet. The formatting is is row 2 and that row is hidden. All of a sudden I am getting a "runtime error 1004 no cells were found." Nothing that I can find has changed that would cause it to stop working.

Column "A - G" contains formulas
Column "H" contains data

If i pull out the
Code:
Range("a9:a" & Rows.Count).SpecialCells(xlBlanks)(1).PasteSpecial Paste:=xlPasteAll

paste it into a new module and change it to

Code:
 Range("H9:H" & Rows.Count).SpecialCells(xlBlanks)(1).PasteSpecial Paste:=xlPasteAll

it will find the cell below the last cell with data which is what I need it to do only in column A




Code:
Private Sub Add_Rows()
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
 
    ActiveSheet.UnProtect
 
    Range("A2:x2").Copy
 
    Range("a9:a" & Rows.Count).SpecialCells(xlBlanks)(1).PasteSpecial Paste:=xlPasteAll
    Range("a9:a" & Rows.Count).SpecialCells(xlBlanks)(1).PasteSpecial Paste:=xlPasteAll
    Range("a9:a" & Rows.Count).SpecialCells(xlBlanks)(1).PasteSpecial Paste:=xlPasteAll
    Range("a9:a" & Rows.Count).SpecialCells(xlBlanks)(1).PasteSpecial Paste:=xlPasteAll
    Range("a9:a" & Rows.Count).SpecialCells(xlBlanks)(1).PasteSpecial Paste:=xlPasteAll
    Range("a9:a" & Rows.Count).SpecialCells(xlBlanks)(1).PasteSpecial Paste:=xlPasteAll
    Range("a9:a" & Rows.Count).SpecialCells(xlBlanks)(1).PasteSpecial Paste:=xlPasteAll
    Range("a9:a" & Rows.Count).SpecialCells(xlBlanks)(1).PasteSpecial Paste:=xlPasteAll
    Range("a9:a" & Rows.Count).SpecialCells(xlBlanks)(1).PasteSpecial Paste:=xlPasteAll
    Range("a9:a" & Rows.Count).SpecialCells(xlBlanks)(1).PasteSpecial Paste:=xlPasteAll
 
    Range("h9:h" & Rows.Count).SpecialCells(xlBlanks)(1).Select
    Selection.Activate
    ActiveSheet.Protect
 
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
 
End Sub

Any suggestions??

Thanks in advance for the help
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,214,567
Messages
6,120,268
Members
448,953
Latest member
Dutchie_1

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