PDA

View Full Version : Get all cells in a column



onlines
01-20-2009, 12:13 PM
How would you go about getting all the cells within say, Column B (even though, glancing at it you can clearly tell it's 31, or 10, or 1)?

nst1107
01-20-2009, 12:23 PM
Not real sure what you're asking, but try a loop to fill an array will the addresses of cells in the column that are not blank. For instance:Sub FillArray()
Dim c as Range
Dim CellArray
For Each c In Sheet1.Columns("B")
If

nst1107
01-20-2009, 12:26 PM
My mistake.
Sub FillArray()
Dim c As Range
Dim CellArray
ReDim CellArray(0)
For Each c In Sheet1.Columns("B")
If c <> vbNullString Then
CellArray(Ubound(CellArray)) = c.Address
ReDim Preserve CellArray(Ubound(CellArray) + 1)
End If
Next

Zack Barresse
01-20-2009, 12:52 PM
Onlines, please describe exactly what it is you need. From what you've posted we cannot give you a solution. Perhaps describe an example, or better yet your data, and what you are trying to achieve with it (or the desired results, preferably both).

Benzadeus
01-21-2009, 03:13 AM
You want only non-blank cells?