xldown in a non-contiguous column

G

Guest

I have a non-contiguous column that I need to read. xldown will only take me
to the first blan row. Is there an alternative to xldown to get to the real
bottom of the column?
 
G

Guest

You bet. xlUp... try this...

dim rng as range
set rng = Sheets("Sheet1").Cells(rows.count, "A").end(xlUp)
msgbox rng.address
 
G

Guest

whoops, I worded that wrong. I want to get to the end of the data. Not the
end of h of the column!
 
G

Guest

Why not try it.

--
regards,
Tom Ogilvy



David Gerstman said:
whoops, I worded that wrong. I want to get to the end of the data. Not the
end of h of the column!
 
G

Guest

Ok... I'm lost. The code posted by Tom and I looks up from the bottom of the
sheet and finds the first non-blank cell in a column. I would have assumed
that would be the end of the data... What exactly are you looking for???
 
G

Guest

This is what I did:

Sub check_names()

Dim ws_name As String

ws_name = "ACTIVE"

Worksheets(ws_name).Activate

Set poc_range = ActiveSheet.Cells(Rows.Count, 2).End(xlUp)

ind = 1

For Each poc In poc_range

ind = ind + 1

Next poc

MsgBox "There were " & ind & " entries."

End Sub

After it ran, ind equalled 2 and not 52. What did I do wrong?
 
G

Guest

OK,
I see what I did wrong. I wanted a range that started at the top and went to
the last row of data. I should have specified that.

I fixed my code to:

Set poc_range = ActiveSheet.Range("b3", Cells(Rows.Count, 2).End(xlUp))

That did the trick.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top