Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Range("A2:A10") is a list of numbers.
I want to search each sheet for each number in the list and return occurrence of each number to column B, next to the number. As posted, code throws 'Subscript out of range' error on the line: With nNumArr(i) I had intended to also list the sheet names in column C and write that sheet list to the varSheets array, but have not got that far. Tried some similar things like the numbers list but that failed also, so I just wrote them in the array in the code as you see them. The numbers list and the sheet list will be much larger in a working code. Thanks, Howard Sub WSnNumCount() Dim nNumArr() As Variant Dim nNumCt As Long Dim varSheets As Variant Dim i As Long, ii As Long, j As Long Dim c As Range nNumArr = Range("A2:A10") varSheets = Array("Sheet2", "Sheet3", "Sheet4", "Sheet5", "Sheet6") For i = LBound(nNumArr) To UBound(nNumArr) With nNumArr(i) For ii = LBound(varSheets) To UBound(varSheets) With Sheets(varSheets(ii)) Set c = .UsedRange.Find(What:=nNumArr(i), LookIn:=xlValues) If Not c Is Nothing Then j = j + 1 End If End With Next ' ii End With Range("B" & Rows.Count).End(xlUp)(2) = j Next 'i j = 0 End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
count array for top three entries and return their number | Excel Discussion (Misc queries) | |||
Which Function to Use? Search an Array, Return a Row Value | Excel Discussion (Misc queries) | |||
Search array and return element No | Excel Worksheet Functions | |||
average of kth largest numbers in an array of n numbers | Excel Worksheet Functions | |||
SEARCH EXCEL ARRAY FOR NON-VOIDS AND ENTER INTO ANOTHER ARRAY, | Excel Programming |