Traversing the collumn of the active cell

S

Sean Farrow

Hi:
I need to traverse the collums of the active cell looking for data, can I
use:
ActiveCell.Collumn.cells in a foreeach loop?
Any help apreciated.
Sean.
 
J

Joel

LastCol = cellls(activecell.row,columns.count).end(xltoleft).column
For ColCount = 1 to Lastcol
Data = .cells(Activecell.row,ColCount)
if Data = "ABC" then
'enter your code here
end if
next ColCount
 
P

Per Jessen

Hi

Try this:

For Each cell In Columns(ActiveCell.Column).Cells
a = a + 1
Next
Debug.Print a

Regards,
Per
 
S

Sean Farrow

Hi:
What does the line:
LastCol = cellls(activecell.row,columns.count).end(xltoleft).column
Achieve?
Cheers
Sean.
 
J

Joel

There should only be two ll (not 3). The line gets the last cell with data
in the column. cells.count is a constant in excel that represents the last
column on the worksheet like in excel 2003 which is column 256.
end(xltoleft) move from column 256 to the left until a cell with data is
found.

You didn't specify how many columns you needed to transverse.
 
S

Sean Farrow

Chers Both, I'#ve solved this.
Sean.
Per Jessen said:
Hi

Try this:

For Each cell In Columns(ActiveCell.Column).Cells
a = a + 1
Next
Debug.Print a

Regards,
Per
 

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