ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If help. Multible IF's (https://www.excelbanter.com/excel-programming/400203-if-help-multible-ifs.html)

David A.

If help. Multible IF's
 
I have this macro that I am trying to run:
Sub RepStats()
On Error Resume Next
Dim rng As range
Set myrng = Worksheets("Rep Page").range("A:A")
For Each c In myrng
If c < "" Then
Sheets("Rep Page").Select
Sheets("Sheet1").Select
Selection.AutoFilter Field:=2, Criteria1:=c.Value
With ActiveSheet.AutoFilter.range
On Error Resume Next
Set rng11 = .Offset(1, 0).Resize(.Rows.Count - 1, _
1).SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With
If rng11 Is Nothing Then
MsgBox em + " **No Data Found For This Rep**"
Else
range("B:B").EntireColumn.Hidden = True
Set rng = ActiveSheet.AutoFilter.range
rng.Offset(1, 0).Resize(rng.Rows.Count - 1).Copy _
Destination:=Worksheets("Rep Page").range(c.Address).Offset(0, 1)
End If
ActiveSheet.ShowAllData
Sheets("Rep Page").Select
End If
Next
End Sub

The thing is that it does everything except:
With ActiveSheet.AutoFilter.range
On Error Resume Next
Set rng11 = .Offset(1, 0).Resize(.Rows.Count - 1, _
1).SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With
If rng11 Is Nothing Then
MsgBox em + " **No Data Found For This Rep**"

Jt just goes to:
Else
range("B:B").EntireColumn.Hidden = True
Set rng = ActiveSheet.AutoFilter.range
rng.Offset(1, 0).Resize(rng.Rows.Count - 1).Copy _
Destination:=Worksheets("Rep Page").range(c.Address).Offset(0, 1)
End If

And copies the entire sheet, not the filtered data.

HElp.



All times are GMT +1. The time now is 10:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com