Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I have a column that conntains years. The column is sorted and probably will not have more than four unique values. The range is about 700 cells. I would like to define Year1 as the earliest year Year2 as the next..... and so on If there is only one year, I would like Year2 = "-". Any help getting me started would be great. Thanks in advance. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dim cell as Range, rng as Range
Dim Flag as Long Dim Year1, Year2, Year3, Year4, Year5 set rng = Range(Cells(1,1),Cells(rows.count,1).End(xlup)) flag = 1 for each cell in range if cell.offset(1,0).Value < cell.value then Select Case Flag Case1 Year1 = cell.Value Year2 = "-" Case 2 Year2 = cell.Value Year3 = "-" Case 3 Year3 = Cell.Value Year4 = "-" Case 4 Year4 = Cell.Value Year5 = "-" End Select Flag = Flag + 1 End if Next debug.print Year1, Year2, Year3, Year4, Year5 If would be easier to use an array. -- Regards, Tom Ogilvy "johnny" wrote in message ... Hello, I have a column that conntains years. The column is sorted and probably will not have more than four unique values. The range is about 700 cells. I would like to define Year1 as the earliest year Year2 as the next..... and so on If there is only one year, I would like Year2 = "-". Any help getting me started would be great. Thanks in advance. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Year1=small(a1:a700,1)
Year2=if(small(a1:a700,2)=small(a1:a700,1),"-",small(a1:a700,2)) Year3=if(small(a1:a700,3)=small(a1:a700,2),"-",small(a1:a700,3)) .... .... YearN=if(small(a1:a700,N)=small(a1:a700,N-1),"-",small(a1:a700,N)). johnny wrote: Hello, I have a column that conntains years. The column is sorted and probably will not have more than four unique values. The range is about 700 cells. I would like to define Year1 as the earliest year Year2 as the next..... and so on If there is only one year, I would like Year2 = "-". Any help getting me started would be great. Thanks in advance. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Unique Values, not Unique Records | Excel Discussion (Misc queries) | |||
Count Unique Values but not Filtered or Hidden Values | Excel Worksheet Functions | |||
Count unique values and create list based on these values | Excel Worksheet Functions | |||
create list of unique values from a column with repeated values? | Excel Worksheet Functions | |||
How do I search thr'o column and put unique values in differnt sheet and sum corresponding values in | Excel Programming |