#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 64
Default Set rng1 not working

I have:
Sub RepStats()
On Error Resume Next
Dim rng1 As range
Set myrng = Worksheets("Rep Page").range("A:A")
For Each c In myrng
If c < "" Then
Sheets("Rep Page").Select
em = c.Value
Sheets("Sheet1").Select
Selection.AutoFilter Field:=2, Criteria1:=em
With ActiveSheet.AutoFilter.range
On Error Resume Next
Set rng1 = Worksheets("Sheet1").Offset(1, 0).Resize(.Rows.Count - 1,
1).SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With
If rng1 Is Nothing Then
MsgBox em + " **No Data Found For This Rep**"
Else
Set rng = ActiveSheet.AutoFilter.range
rng.Offset(1, 0).Resize(rng.Rows.Count - 1).Copy _
Destination:=Worksheets("Rep Page").range("B2")
End If

ActiveSheet.ShowAllData
Sheets("Rep Page").Select
End If
Next
End Sub

The line:
On Error Resume Next
Set rng1 = Worksheets("Sheet1").Offset(1, 0).Resize(.Rows.Count - 1,
1).SpecialCells(xlCellTypeVisible)
On Error GoTo 0

Is not working. Can you help me. There is data that is filtered but it wont
copy, it just goes to:
If rng1 Is Nothing Then
MsgBox em + " **No Data Found For This Rep**"
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default Set rng1 not working

David,

Worksheets doesn't have an offset property:

Set rng1 = Worksheets("Sheet1").Offset(1, 0).Resize(.Rows.Count - 1,
1).SpecialCells(xlCellTypeVisible)

Try just this, since you use the With construction:

Set rng1 = .Offset(1, 0).Resize(.Rows.Count - 1,
1).SpecialCells(xlCellTypeVisible)

HTH,
Bernie
MS Excel MVP


"David A." wrote in message
...
I have:
Sub RepStats()
On Error Resume Next
Dim rng1 As range
Set myrng = Worksheets("Rep Page").range("A:A")
For Each c In myrng
If c < "" Then
Sheets("Rep Page").Select
em = c.Value
Sheets("Sheet1").Select
Selection.AutoFilter Field:=2, Criteria1:=em
With ActiveSheet.AutoFilter.range
On Error Resume Next
Set rng1 = Worksheets("Sheet1").Offset(1, 0).Resize(.Rows.Count - 1,
1).SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With
If rng1 Is Nothing Then
MsgBox em + " **No Data Found For This Rep**"
Else
Set rng = ActiveSheet.AutoFilter.range
rng.Offset(1, 0).Resize(rng.Rows.Count - 1).Copy _
Destination:=Worksheets("Rep Page").range("B2")
End If

ActiveSheet.ShowAllData
Sheets("Rep Page").Select
End If
Next
End Sub

The line:
On Error Resume Next
Set rng1 = Worksheets("Sheet1").Offset(1, 0).Resize(.Rows.Count - 1,
1).SpecialCells(xlCellTypeVisible)
On Error GoTo 0

Is not working. Can you help me. There is data that is filtered but it wont
copy, it just goes to:
If rng1 Is Nothing Then
MsgBox em + " **No Data Found For This Rep**"



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 64
Default Set rng1 not working

That worked. One more thing, How do I get it to paste in the cell next to the
"em" value?

"Bernie Deitrick" wrote:

David,

Worksheets doesn't have an offset property:

Set rng1 = Worksheets("Sheet1").Offset(1, 0).Resize(.Rows.Count - 1,
1).SpecialCells(xlCellTypeVisible)

Try just this, since you use the With construction:

Set rng1 = .Offset(1, 0).Resize(.Rows.Count - 1,
1).SpecialCells(xlCellTypeVisible)

HTH,
Bernie
MS Excel MVP


"David A." wrote in message
...
I have:
Sub RepStats()
On Error Resume Next
Dim rng1 As range
Set myrng = Worksheets("Rep Page").range("A:A")
For Each c In myrng
If c < "" Then
Sheets("Rep Page").Select
em = c.Value
Sheets("Sheet1").Select
Selection.AutoFilter Field:=2, Criteria1:=em
With ActiveSheet.AutoFilter.range
On Error Resume Next
Set rng1 = Worksheets("Sheet1").Offset(1, 0).Resize(.Rows.Count - 1,
1).SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With
If rng1 Is Nothing Then
MsgBox em + " **No Data Found For This Rep**"
Else
Set rng = ActiveSheet.AutoFilter.range
rng.Offset(1, 0).Resize(rng.Rows.Count - 1).Copy _
Destination:=Worksheets("Rep Page").range("B2")
End If

ActiveSheet.ShowAllData
Sheets("Rep Page").Select
End If
Next
End Sub

The line:
On Error Resume Next
Set rng1 = Worksheets("Sheet1").Offset(1, 0).Resize(.Rows.Count - 1,
1).SpecialCells(xlCellTypeVisible)
On Error GoTo 0

Is not working. Can you help me. There is data that is filtered but it wont
copy, it just goes to:
If rng1 Is Nothing Then
MsgBox em + " **No Data Found For This Rep**"




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default Set rng1 not working

David,

Try:

rng.Offset(1, 0).Resize(rng.Rows.Count - 1).Copy _
Destination:=Worksheets("Rep Page").Range(C.Address).Offset(0, 1)

Although you are switching from rng1 to rng - not sure what exactly you want to do...

HTH,
Bernie
MS Excel MVP

"David A." wrote in message
...
That worked. One more thing, How do I get it to paste in the cell next to the
"em" value?

"Bernie Deitrick" wrote:

David,

Worksheets doesn't have an offset property:

Set rng1 = Worksheets("Sheet1").Offset(1, 0).Resize(.Rows.Count - 1,
1).SpecialCells(xlCellTypeVisible)

Try just this, since you use the With construction:

Set rng1 = .Offset(1, 0).Resize(.Rows.Count - 1,
1).SpecialCells(xlCellTypeVisible)

HTH,
Bernie
MS Excel MVP


"David A." wrote in message
...
I have:
Sub RepStats()
On Error Resume Next
Dim rng1 As range
Set myrng = Worksheets("Rep Page").range("A:A")
For Each c In myrng
If c < "" Then
Sheets("Rep Page").Select
em = c.Value
Sheets("Sheet1").Select
Selection.AutoFilter Field:=2, Criteria1:=em
With ActiveSheet.AutoFilter.range
On Error Resume Next
Set rng1 = Worksheets("Sheet1").Offset(1, 0).Resize(.Rows.Count - 1,
1).SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With
If rng1 Is Nothing Then
MsgBox em + " **No Data Found For This Rep**"
Else
Set rng = ActiveSheet.AutoFilter.range
rng.Offset(1, 0).Resize(rng.Rows.Count - 1).Copy _
Destination:=Worksheets("Rep Page").range("B2")
End If

ActiveSheet.ShowAllData
Sheets("Rep Page").Select
End If
Next
End Sub

The line:
On Error Resume Next
Set rng1 = Worksheets("Sheet1").Offset(1, 0).Resize(.Rows.Count - 1,
1).SpecialCells(xlCellTypeVisible)
On Error GoTo 0

Is not working. Can you help me. There is data that is filtered but it wont
copy, it just goes to:
If rng1 Is Nothing Then
MsgBox em + " **No Data Found For This Rep**"






  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 64
Default Set rng1 not working

THANK YOU!!!!!! Man I was killing myself trying to figure that out......

"Bernie Deitrick" wrote:

David,

Try:

rng.Offset(1, 0).Resize(rng.Rows.Count - 1).Copy _
Destination:=Worksheets("Rep Page").Range(C.Address).Offset(0, 1)

Although you are switching from rng1 to rng - not sure what exactly you want to do...

HTH,
Bernie
MS Excel MVP

"David A." wrote in message
...
That worked. One more thing, How do I get it to paste in the cell next to the
"em" value?

"Bernie Deitrick" wrote:

David,

Worksheets doesn't have an offset property:

Set rng1 = Worksheets("Sheet1").Offset(1, 0).Resize(.Rows.Count - 1,
1).SpecialCells(xlCellTypeVisible)

Try just this, since you use the With construction:

Set rng1 = .Offset(1, 0).Resize(.Rows.Count - 1,
1).SpecialCells(xlCellTypeVisible)

HTH,
Bernie
MS Excel MVP


"David A." wrote in message
...
I have:
Sub RepStats()
On Error Resume Next
Dim rng1 As range
Set myrng = Worksheets("Rep Page").range("A:A")
For Each c In myrng
If c < "" Then
Sheets("Rep Page").Select
em = c.Value
Sheets("Sheet1").Select
Selection.AutoFilter Field:=2, Criteria1:=em
With ActiveSheet.AutoFilter.range
On Error Resume Next
Set rng1 = Worksheets("Sheet1").Offset(1, 0).Resize(.Rows.Count - 1,
1).SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With
If rng1 Is Nothing Then
MsgBox em + " **No Data Found For This Rep**"
Else
Set rng = ActiveSheet.AutoFilter.range
rng.Offset(1, 0).Resize(rng.Rows.Count - 1).Copy _
Destination:=Worksheets("Rep Page").range("B2")
End If

ActiveSheet.ShowAllData
Sheets("Rep Page").Select
End If
Next
End Sub

The line:
On Error Resume Next
Set rng1 = Worksheets("Sheet1").Offset(1, 0).Resize(.Rows.Count - 1,
1).SpecialCells(xlCellTypeVisible)
On Error GoTo 0

Is not working. Can you help me. There is data that is filtered but it wont
copy, it just goes to:
If rng1 Is Nothing Then
MsgBox em + " **No Data Found For This Rep**"






Reply
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
IF not working amandooshna Excel Worksheet Functions 9 March 28th 07 02:11 PM
working Chris Lane Excel Worksheet Functions 2 November 19th 05 11:32 AM
Why is this not working? R.P.McMurphy Excel Discussion (Misc queries) 6 August 30th 05 09:34 PM
F4 Key not working.... Calvin Excel Discussion (Misc queries) 2 July 29th 05 09:03 AM
Working out UK tax hawkeye uk New Users to Excel 6 March 11th 05 04:23 PM


All times are GMT +1. The time now is 11:18 AM.

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

About Us

"It's about Microsoft Excel"