View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Combined code not working

hi,
that line of code is trying to select a range on a sheet
named charts and it can't find charts.
go through the code and change "charts" to the sheet in
the new workbook.

-----Original Message-----
The following code (below) has been pieced together from

individual modules
and works when run from the worksheet titled "Charts!"

When I try to run it
from another sheet I get the following message : Runtime

error '1004'
Selection method of range class failed and the debug

highlights the
following line of code:

Range("Charts!b25:b56").Select




Sub Delete_CR()
Dim Rng As Range, rng1 As Range
On Error Resume Next
Set Rng = Range("Charts!B25:IV26").SpecialCells

(xlFormulas, xlErrors)
On Error GoTo 0
If Not Rng Is Nothing Then Rng.EntireColumn.Delete
Dim n As Long, lastrow As Long
lastrow = Range("Charts!B52").End(xlUp).Row
For n = lastrow To 2 Step -1
If Cells(n, 2) = "Grand Total" Or Cells(n, 2)

= "0" _
Then Cells(n, 2).EntireRow.Delete
Next n
Range("Charts!b25:b56").Select
For Each Rng In Selection.Cells
If Rng.Interior.ColorIndex = 1 Then
Rng.EntireRow.Hidden = True
End If
Next Rng
End Sub


.