Consulting

Results 1 to 5 of 5

Thread: Get all cells in a column

  1. #1

    Get all cells in a column

    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)?

  2. #2
    VBAX Tutor nst1107's Avatar
    Joined
    Nov 2008
    Location
    Monticello
    Posts
    245
    Location
    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:[VBA]Sub FillArray()
    Dim c as Range
    Dim CellArray
    For Each c In Sheet1.Columns("B")
    If
    [/VBA]

  3. #3
    VBAX Tutor nst1107's Avatar
    Joined
    Nov 2008
    Location
    Monticello
    Posts
    245
    Location
    My mistake.[VBA]
    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
    [/VBA]

  4. #4
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,938
    Location
    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).

  5. #5
    VBAX Tutor Benzadeus's Avatar
    Joined
    Dec 2008
    Location
    Belo Horizonte, Brazil
    Posts
    271
    Location
    You want only non-blank cells?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •