Trying to work around Runtime Error 1004: No Visible Cells

Metzy7

New Member
Joined
Feb 27, 2009
Messages
11
I'm trying to run a Macro that returns the revenue for a list of clients for a given office. I then set up an autofilter to hide rows with clients that have zero revenue, and then copy the visible clients (those with revenue) to an output worksheet. However, some offices don't have any clients with revenue, which is intentional. I'm looking for a work around so that it will capture the visible clients (when they exist) or just move on to the next office if there are not any clients with revenue for that office. Below is the macro that I have set up so far. Any help on how to put a work around into the macro would be greatly appreciated.

Sub Refresh()
Dim x As Integer
x = 3508
Do Until x = 3510
Worksheets("Client Revenue").Activate
Selection.AutoFilter Field:=1
Cells.Item(x, 2).Select
Selection.Copy
Range("F1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
ActiveSheet.Outline.ShowLevels RowLevels:=2, ColumnLevels:=2
ActiveSheet.Calculate
Application.Run "ImportWorksheet"
ActiveSheet.Calculate

ActiveSheet.Outline.ShowLevels RowLevels:=1, ColumnLevels:=1
Selection.AutoFilter Field:=1, Criteria1:="TRUE", Operator:=xlAnd
Selection.EntireColumn.Hidden = False
Dim R As Integer
For R = 6 To 96

Worksheets("Output").Activate
If Cells(R, 1) = Worksheets("Client Revenue").Cells(1, 6) Then
Sheets("Client Revenue").Select
Range("P2975:P3475").Select
Selection.SpecialCells (xlCellTypeVisible)
Selection.Copy
Sheets("Output").Select
Cells.Item(R, 5).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=True

End If

Next R
x = x + 1
Loop
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Worksheets("Client Revenue").Select
End Sub
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Maybe like this

Code:
If Cells(R, 1) = Worksheets("Client Revenue").Cells(1, 6) Then
    On Error Resume Next
    Sheets("Client Revenue").Range("P2975:P3475").SpecialCells(xlCellTypeVisible).Copy
    Sheets("Output").Cells.Item(R, 5).PasteSpecial Paste:=xlPasteValues
    On Error GoTo 0
End If
 
Upvote 0

Forum statistics

Threads
1,224,542
Messages
6,179,424
Members
452,914
Latest member
echoix

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