ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Traversing the collumn of the active cell (https://www.excelbanter.com/excel-programming/421576-traversing-collumn-active-cell.html)

Sean Farrow

Traversing the collumn of the active cell
 
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.



joel

Traversing the collumn of the active cell
 


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

"Sean Farrow" wrote:

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.




Per Jessen

Traversing the collumn of the active cell
 
Hi

Try this:

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

Regards,
Per

"Sean Farrow" skrev i meddelelsen
...
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.



Sean Farrow

Traversing the collumn of the active cell
 
Hi:
What does the line:
LastCol = cellls(activecell.row,columns.count).end(xltoleft) .column
Achieve?
Cheers
Sean.
"Joel" wrote in message
...


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

"Sean Farrow" wrote:

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.






joel

Traversing the collumn of the active cell
 
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.

"Sean Farrow" wrote:

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


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

"Sean Farrow" wrote:

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.







Sean Farrow

Traversing the collumn of the active cell
 
Chers Both, I'#ve solved this.
Sean.
"Per Jessen" wrote in message
...
Hi

Try this:

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

Regards,
Per

"Sean Farrow" skrev i meddelelsen
...
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.






All times are GMT +1. The time now is 12:30 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com