ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using for next with two counters (https://www.excelbanter.com/excel-programming/313596-using-next-two-counters.html)

Albert Jameson

Using for next with two counters
 
Hi All,

Im trying to use a for next statement with two counters.
What i have so far:

DDRowCount and DateCount1 are variables defined earlier.
say DDRowCount = 4 and DateCount1 = 5
DataRange is a variable too, of the rows of data.

For n = 1 To DRRowCount
For d = 1 To DateCount1 + 5
DataRange.Cells(n, d).Value = "test"
Next d
Next n

This doesn't seem to be working.
Can i please ask for some help on this.

Cheers.
Alby


Jim Cone

Using for next with two counters
 
Albert,

Always use Option Explicit as the top of your modules.
Doing that would quickly point out that...

DDRowCount is not the same as DRRowCount
It works for me after making the correction.

Regards,
Jim Cone San Francisco, CA


"Albert Jameson" wrote in message
...
Hi All,
Im trying to use a for next statement with two counters.
What i have so far:
DDRowCount and DateCount1 are variables defined earlier.
say DDRowCount = 4 and DateCount1 = 5
DataRange is a variable too, of the rows of data.
For n = 1 To DRRowCount
For d = 1 To DateCount1 + 5
DataRange.Cells(n, d).Value = "test"
Next d
Next n
This doesn't seem to be working.
Can i please ask for some help on this.
Cheers.
Alby



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

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