Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default simple looping question

I have what I hope is a simple looping question: I'm trying to
filter each of many worksheets in a workbook for the unique values
in a particular column, and then "unfilter" the whole workbook. My
"unique" function enters an infinite loop, I think. Any clues?

Sub unique()

Dim ws As Worksheet

For Each ws In Worksheets
'Columns("B:B").Select
ws.UsedRange.AdvancedFilter Action:=xlFilterInPlace, unique:=True
Next

End Sub


Sub ununique()

Dim ws As Worksheet

For Each ws In Worksheets
ActiveSheet.ShowAllData
Next

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default simple looping question

Hi
This worked for me
Sub unique()
Dim ws As Worksheet
For Each ws In Worksheets
ws.UsedRange.AdvancedFilter Action:=xlFilterInPlace,
unique:=True
Next
End Sub


Sub ununique()
Dim ws As Worksheet
For Each ws In Worksheets
ws.ShowAllData
Next
End Sub

this was tested on two sheets which had the data
Name
Paul
John
Paul

in column A. Perhaps your problem is with the data? Do your columns
have headers?

regards
Paul


Person wrote:

I have what I hope is a simple looping question: I'm trying to
filter each of many worksheets in a workbook for the unique values
in a particular column, and then "unfilter" the whole workbook. My
"unique" function enters an infinite loop, I think. Any clues?

Sub unique()

Dim ws As Worksheet

For Each ws In Worksheets
'Columns("B:B").Select
ws.UsedRange.AdvancedFilter Action:=xlFilterInPlace, unique:=True
Next

End Sub


Sub ununique()

Dim ws As Worksheet

For Each ws In Worksheets
ActiveSheet.ShowAllData
Next

End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default simple looping question

Not sure about the infinite loop, but your ununique() subroutine is not
going
to work, as you are referencing ActiveSheet instead of your loop
variable.

Scott

Person wrote:
I have what I hope is a simple looping question: I'm trying to
filter each of many worksheets in a workbook for the unique values
in a particular column, and then "unfilter" the whole workbook. My
"unique" function enters an infinite loop, I think. Any clues?

Sub unique()

Dim ws As Worksheet

For Each ws In Worksheets
'Columns("B:B").Select
ws.UsedRange.AdvancedFilter Action:=xlFilterInPlace, unique:=True
Next

End Sub


Sub ununique()

Dim ws As Worksheet

For Each ws In Worksheets
ActiveSheet.ShowAllData
Next

End Sub


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 formula-simple question; simple operator Rich D Excel Discussion (Misc queries) 4 December 6th 07 03:36 PM
Help with simple looping program Stephen Excel Programming 2 August 4th 06 06:55 PM
Simple looping question light Excel Programming 2 August 19th 05 09:28 PM
Simple looping question light Excel Programming 2 August 16th 05 06:30 PM
Simple Array Looping Nikky Excel Programming 2 April 20th 05 10:38 PM


All times are GMT +1. The time now is 09:56 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"