ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Question: Range().Select for more than one row? (https://www.excelbanter.com/excel-programming/271666-question-range-select-more-than-one-row.html)

Hannibal

Question: Range().Select for more than one row?
 
Hi,

I need some help with a little VBA problem:

Is there any way to test cells in a range, say 10x10, within one or two loop(s)?

I figured out how I can do it in a row, but I need a whole range.
my Code:

Counter = 0
Range("A1").Select
Do While Counter < 10
If ActiveCell.Value a Then MsgBox " Message "
Counter = Counter + 1
ActiveCell.Next.Select
Loop

any idea for my solution?

Charles Williams

Question: Range().Select for more than one row?
 
Hi Hannibal,

you dont need to select; it just slows things down.
Try something like

dim oCell as range

for each oCell in Range("A1:z99")
if ocell.valuea then msgbox "Message"
next


Charles
______________________
Decision Models
The Excel Calculation Site
www.DecisionModels.com

"Hannibal" wrote in message
om...
Hi,

I need some help with a little VBA problem:

Is there any way to test cells in a range, say 10x10, within one or two

loop(s)?

I figured out how I can do it in a row, but I need a whole range.
my Code:

Counter = 0
Range("A1").Select
Do While Counter < 10
If ActiveCell.Value a Then MsgBox " Message "
Counter = Counter + 1
ActiveCell.Next.Select
Loop

any idea for my solution?





All times are GMT +1. The time now is 01:36 PM.

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