Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting Data in Exel spreadsheet using VB6.

Status
Not open for further replies.

cassidybklyn

Programmer
Apr 23, 2007
82
US
Gentlemen,
I am performing a count of unique items using "Subtotal" function. It is giving me count of the unique items everywhere they appear in the column.

What I want to do is first sort the unique items so that all unique items appear in a single location, then afterwards I can do my count.

This is the code I'm using to accomplish my count:

Selection.Subtotal groupBy:=7, Function:=xlCount, TotalList:=Array(7), _
PageBreak:=False, SummaryBelowData:=True

In otherwords, I want to sort the records based on the 7 column before executing the above routine.

Thank you.
C.

 
Use the macrorecorder when doing it manually.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PH,
but I want to Sort the spreadsheet in VB (automate), not manually. I want to sort it before execting the Count routine below. Any Ideas?
Thanks.

*****Count routine******
Selection.Subtotal groupBy:=7, Function:=xlCount, TotalList:=Array(7), _
PageBreak:=False, SummaryBelowData:=True

In otherwords, I want to sort the records based on the 7 column before executing the above routine.

Thank you.
C.
 
If you follow my suggestion then you'll get VBA code ...
 
To launch the macrorecorder:
menu Tools -> Macro -> New macro

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top