LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Need macro to analyse a column

Here is a code. It assumes that the original data has a header

Const target As String = "M1"
Dim iLastrow As Long
Dim iLastrow1 As Long
iLastrow = Cells(Rows.Count, "A").End(xlUp).Row
With Range("A1:A" & iLastrow)
.AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=Range(target), _
Unique:=True
End With

iLastrow1 = Cells(Rows.Count, Range(target).Column).End(xlUp).Row
With Range(target)
.Offset(0, 1).Value = "Count"
.Offset(0, 2).Value = "Value"
With .Offset(1, 1)
.Formula = "=COUNTIF(A:A," & .Offset(0, -1).Address(False) & ")"
.Offset(0, 1).Formula = "=SUMPRODUCT(--(A1:A" & iLastrow & "=" &
_
.Offset(0, -1).Address(False) & " ),B1:B" &
iLastrow & ")"
.Resize(1, 2).AutoFill .Resize(iLastrow1 - 1, 2)
End With
End With


--
HTH

Bob Phillips

"abrogard" wrote in
message ...

I have a spreadsheet with a very long column containing many different
things that have been purchased in the past.

I need to discover how many different things have been purchased and
list them and find out how much has been spent on each of those
things.

So I need a method (a macro I suppose) of going down that column and
finding the first entry that hasn't already been dealt with - say
'screwdriver 6inch' and then continue down the column, find every
instance and take the cost (and date) and write it to some other part
of the spreadsheet.

When we finish I'll have columns for every different article. I can
look at what they are, know how many there are and see the total
expenditures.

I imagine this is the gist of what spreadsheets are for yet I can't
figure out how to do it automatically, not for reading all the help
screens I can't.

Perhaps it is too easy and there's couple of clicks will do it?

Please help if you know.

regards,
ab.
:)


--
abrogard
------------------------------------------------------------------------
abrogard's Profile:

http://www.excelforum.com/member.php...o&userid=24236
View this thread: http://www.excelforum.com/showthread...hreadid=378471



 
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
Formula - Analyse range, return unique value S Davis Excel Worksheet Functions 4 February 20th 07 11:16 PM
how do you use a chisquare function to analyse data mada Excel Worksheet Functions 1 May 10th 06 02:03 PM
how do I analyse two spreadsheets for missing data? [email protected] Excel Discussion (Misc queries) 2 March 31st 06 03:18 PM
How do i analyse visible rows only in excel? Dr Happy Excel Worksheet Functions 8 December 6th 05 05:13 PM
vB code to analyse list scottwilsonx Excel Programming 2 June 30th 04 10:07 AM


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