montecarlo2012
Well-known Member
- Joined
- Jan 26, 2011
- Messages
- 985
- Office Version
- 2010
- Platform
- Windows
Hello.
the following code, work good as long my range is fix
My concern now is to see the code working with a dynamic range.
the way I can explain what I am looking for is the code as a pseudocode:
So the process done in: ‘Set rngData = Sheet1.Range("B2 to the last Row").......1
Will display the results on: 'Sheet3.Range("C2").Offset(0, m) = n...........1
And so on
Please. I need more than one hand here,
Thank you for reading this.
the following code, work good as long my range is fix
VBA Code:
Sub L_100m()
Set rngData = Sheet1.Range("B2", "B2912")
m = -1
For Each cell In rngData
If cell = 1 Then
Sheet2.Range("C2").Offset(0, m) = n
n = 0
m = m + 1
Else
n = n + 1
End If
Next
End Sub
My concern now is to see the code working with a dynamic range.
the way I can explain what I am looking for is the code as a pseudocode:
VBA Code:
Sub L_101B()
For i = 1 To 6
'Set rngData = Sheet1.Range("B2 to the last Row").......1
'Set rngData = Sheet1.Range("C2 to the last Row")........2
'Set rngData = Sheet1.Range("D2 to the last Row")........3
'Set rngData = Sheet1.Range("E2 to the last Row")........4
'Set rngData = Sheet1.Range("F2 to the last Row").........5
'Set rngData = Sheet1.Range("G2 to the last Row").........6
m = -1
For Each cell In rngData
If cell = 2 Then
'Sheet3.Range("C2").Offset(0, m) = n...........1
'Sheet3.Range("C18").Offset(0, m) = n..............2
'Sheet3.Range("C34").Offset(0, m) = n...........3
'Sheet3.Range("C50").Offset(0, m) = n.............4
'Sheet3.Range("C66").Offset(0, m) = n.............5
'Sheet3.Range("C82").Offset(0, m) = n.............6
n = 0
m = m + 1
Else
n = n + 1
End If
Next
Next i
End Sub
So the process done in: ‘Set rngData = Sheet1.Range("B2 to the last Row").......1
Will display the results on: 'Sheet3.Range("C2").Offset(0, m) = n...........1
And so on
Please. I need more than one hand here,
Thank you for reading this.