ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   loop (https://www.excelbanter.com/excel-programming/301639-loop.html)

LiSa

loop
 
Hi

I know you can do a loop for each worksheet in the
workbook, but can you do one for each cell within a range
eg C4:H9
If so, how ?

ty :)

Ken Wright

loop
 
Sub Chng()
For Each Cel In Range("C4:H9")
Cel.Value = Cel.Value * 2
Next Cel
End Sub

or

Sub Chng()
Set Rng = Range("C4:H9")
For Each Cel In Rng
Cel.Value = Cel.Value * 2
Next Cel
End Sub

etc

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------



"LiSa" wrote in message
...
Hi

I know you can do a loop for each worksheet in the
workbook, but can you do one for each cell within a range
eg C4:H9
If so, how ?

ty :)



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.703 / Virus Database: 459 - Release Date: 10/06/2004




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

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