LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Combined code not working

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


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB code is not working like it should Bob Reynolds[_3_] Excel Programming 8 July 19th 04 12:02 AM
Code not working Todd Huttenstine Excel Programming 1 June 10th 04 05:06 PM
Code not Working - Help please Brian Excel Programming 2 November 18th 03 10:58 PM
Code not working Bob Phillips[_5_] Excel Programming 5 August 14th 03 03:12 PM
For Each Code Not Working jacqui[_2_] Excel Programming 4 July 29th 03 02:44 AM


All times are GMT +1. The time now is 11:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"