LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Difficulty with code

Try this code:

Sub List10()
Dim varr() As Variant
Dim i as long, j as long
Dim res as variant, res1 as variant
Dim cell as Range
ReDim varr(1 To 30)
i = 0
j = 0
For Each cell In Range("C10:L12")
j = j + 1
res = Application.Small(Range("C10:L12"), j)
If Not IsError(res) Then
If i = 0 Then
varr(1) = res
i = 1
Else
res1 = Application.Match(res, varr, 0)
If IsError(res1) Then
i = i + 1
varr(i) = res
End If
End If
End If
Next
Range("C15:L15").Value = varr
End Sub

--
Regards,
Tom Ogilvy

__
"Rick" wrote in message
...
3 16 1 3 2 2 empty etc
8 10 8 13 1 1 empty etc
4 2 4 1 4 14 empty etc

Above is the matrix C10 to L12 (k and L are not shown)

This is what I need extracted and entered in C15 to L15
2 3 4 8 10 13 14 16

The problem:-
I have a macro that extracts a number from the above
matrix and enters it in cell M6.
In the example the number is 1.
The matrix is C10:L12
Some of the cells do not contain data. (empty)
Some of the numbers are repeated.
Sometimes all cells are filled and there are no empties.

I'm trying to extract all the numbers in numeric order
EXCLUDING any that are repeated AND excluding the number
my macro inserts in M6. This number is always one of the
numbers in the matrix.
I wish to enter these numbers as above in numeric order in
cells C15 to L15.
I only need to extract 10 numbers, so any over this can be
dropped.

I have a macro to do this but it won't run on my version
of excel which is for Win95 ver7.

This is the code and I can't get past Dim cX as Collection.
Also Set cX = New Collection is in red.

Sub List_across_row()

Dim c As Range
Dim cX As Collection
Dim iCt As Integer

Set cX = New Collection
For Each c In Sheets("Sheet1").Range("C10:E12")
On Error Resume Next
cX.Add c.Value, CStr(c.Value)
Next c

For iCt = 1 To cX.Count
Sheets("Sheet1").Cells(15 + iCt, 3) = cX(iCt)
Next iCt

iCt = Sheets("Sheet1").Range("C16384").End
(xlUp).Row ' 65536
Set rng = Sheets("Sheet1").Range("C16:C" & iCt)
rng.Sort key1:=Range("C16"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom
rng.Copy
Sheets("Sheet1").Range("C15").PasteSpecial Paste:=xlAll,
_
Operation:=xlNone, SkipBlanks:=False,
Transpose:=True
rng.Clear

End Sub

I don't know whether the rest of the macro runs correctly
as it has not run past the points mentioned above.
I suspect my version of Excel does not support the code.

Would anyone be able to help me get this code to run or
suggest some alternative code that gets around my
problem.

Thankyou in advance.

Regards,
Rick



 
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
Function Difficulty Johnnie[_2_] Excel Discussion (Misc queries) 5 October 20th 08 09:54 PM
Formula difficulty Pyrite Excel Discussion (Misc queries) 5 October 8th 08 08:13 PM
Difficulty in transposing Richard J New Users to Excel 12 August 6th 06 09:53 AM
VLOOKUP Difficulty Serge Excel Discussion (Misc queries) 5 June 21st 06 02:50 AM
IF Statement difficulty susan hayes Excel Worksheet Functions 3 November 2nd 04 09:46 PM


All times are GMT +1. The time now is 09:52 PM.

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"