ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Looping through (active??) cells problem (https://www.excelbanter.com/excel-programming/308619-looping-through-active-cells-problem.html)

Neil[_9_]

Looping through (active??) cells problem
 
Hello All,

I have an excel workbook which has some fields set as the £ currency format.
I would like to be able to programatically loop through all active cells in
each worksheet - check to see if the format is pounds and then change them
to say ? or $ if required. I know how to do everything except for looping
through the cells.

Is there any way of getting the Active Cell range for a worksheet?

The only way i can do it at the moment is loop through all cells (which
would take a LONG time) or loop through a set number of cells that i
specify - the only problem with doing this is if a user was to insert more
rows and the rows go outside the set range then these cells are not updated.
I am sure i am missing something so simple...

Any help is greatly appreciated,

Neil.



JulieD

Looping through (active??) cells problem
 
Hi Neil

by ACTIVE CELL RANGE do you mean the currently selected cells?

if so then you can do the following

For Each cell In Selection
'do whatever
Next

Cheers
JulieD

"Neil" wrote in message
...
Hello All,

I have an excel workbook which has some fields set as the £ currency

format.
I would like to be able to programatically loop through all active cells

in
each worksheet - check to see if the format is pounds and then change them
to say ? or $ if required. I know how to do everything except for looping
through the cells.

Is there any way of getting the Active Cell range for a worksheet?

The only way i can do it at the moment is loop through all cells (which
would take a LONG time) or loop through a set number of cells that i
specify - the only problem with doing this is if a user was to insert more
rows and the rows go outside the set range then these cells are not

updated.
I am sure i am missing something so simple...

Any help is greatly appreciated,

Neil.





Tom Ogilvy

Looping through (active??) cells problem
 
for each cell in Activesheet.UsedRange

Next

--
Regards,
Tom Ogilvy

"Neil" wrote in message
...
Hello All,

I have an excel workbook which has some fields set as the £ currency

format.
I would like to be able to programatically loop through all active cells

in
each worksheet - check to see if the format is pounds and then change them
to say ? or $ if required. I know how to do everything except for looping
through the cells.

Is there any way of getting the Active Cell range for a worksheet?

The only way i can do it at the moment is loop through all cells (which
would take a LONG time) or loop through a set number of cells that i
specify - the only problem with doing this is if a user was to insert more
rows and the rows go outside the set range then these cells are not

updated.
I am sure i am missing something so simple...

Any help is greatly appreciated,

Neil.





Neil[_9_]

Looping through (active??) cells problem
 
Thanks for you replies, it was UsedRange that i needed to use and it works
great (Cheers for that Tom).

Neil.




All times are GMT +1. The time now is 03:20 PM.

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