ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Looping through Cells (https://www.excelbanter.com/excel-programming/354905-looping-through-cells.html)

Bill

Looping through Cells
 
I need to loop through cells B9, B11, B13, B15, B17, B19, B21 (seven total)
and fill each with a date that is located in M4. End the process after the
last one

B9 = M4-13
B11 = M4-12
B13 = M4 -11
B15 = M4 -10
B17 = M4 -9
B19 = M4 -8
B21 = M4 -7

Any help is appreciated. Thanks



Tom Ogilvy

Looping through Cells
 
Sub AddDates()
Dim cell as Range, j as Long
j = 13
for each cell in Range("B9,B11,B13,B15,B17,B19,B21")
cell.Value = Range("M4").Value - j
cell.Numberformat = "mm/dd/yyyy"
j = j - 1
Next
End Sub

--
Regards,
Tom Ogilvy

"Bill" wrote in message
...
I need to loop through cells B9, B11, B13, B15, B17, B19, B21 (seven

total)
and fill each with a date that is located in M4. End the process after the
last one

B9 = M4-13
B11 = M4-12
B13 = M4 -11
B15 = M4 -10
B17 = M4 -9
B19 = M4 -8
B21 = M4 -7

Any help is appreciated. Thanks






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

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