I've got a spreadsheet with data that's imported from an Access database. The data is comprised of eight numbers, filling in columns A through H, through row 422. There's a number in the H column for each row which indicates what type of data it is.
Here's what I'd like to do: There are 13 different types of data that I'm tracking, indicated by the numbers 10 - 22. What I need to do is create a When/Wend loop that will go down through column H, find a cell that contains the number 10, takes the value from the F column in this same row and stores it. And I want it to keep doing that until it reaches row 422. The result is to be inserted into another cell.
Here's the code I have so far:
Sub Array_count()
Dim Cell As Integer
Dim Index As Integer
Index = 1
While (Index <= 422)
If Sheet1.Range("Hindex"
= "10" Then Cell = (Cell + Sheet1.Range("Findex"
)
Index = Index + 1
Wend
Sheet1.Range("K4"
.Value = Cell
End Sub
This works if I put actual numbers where index is in the code, but I can't figure out how to put the incrementing value, index, in place of the cell number. Can someone please throw me a bone here?
Thanks!
Mike
![[morning] [morning] [morning]](/data/assets/smilies/morning.gif)
Here's what I'd like to do: There are 13 different types of data that I'm tracking, indicated by the numbers 10 - 22. What I need to do is create a When/Wend loop that will go down through column H, find a cell that contains the number 10, takes the value from the F column in this same row and stores it. And I want it to keep doing that until it reaches row 422. The result is to be inserted into another cell.
Here's the code I have so far:
Sub Array_count()
Dim Cell As Integer
Dim Index As Integer
Index = 1
While (Index <= 422)
If Sheet1.Range("Hindex"
Index = Index + 1
Wend
Sheet1.Range("K4"
End Sub
This works if I put actual numbers where index is in the code, but I can't figure out how to put the incrementing value, index, in place of the cell number. Can someone please throw me a bone here?
Thanks!
Mike
![[morning] [morning] [morning]](/data/assets/smilies/morning.gif)