montecarlo2012
Well-known Member
- Joined
- Jan 26, 2011
- Messages
- 984
- Office Version
- 2010
- Platform
- Windows
Hello everyone.
I am here trying to see the transformation from a simple Macro to a Code, I know guy for you is something so Simple, but “ sorry “ no for me, I am a new self-thaught bee.
I just sum two numbers with the macro recorder I got this:
Range("H2").Select
ActiveCell.Formula = "=SUM(A2:B2)"
So with my Basic knowledge I see that H2 has to be a variable, sum I can think as a total, or another variable, and the two location as well, so I got this:
Sub real_code()
Dim H As Integer, A As Integer, B As Integer
A = Range("A2").Value: B = Range("B2").Value
H = A + B
Range("H1").Value = H
End Sub
And “”Bingo”” work well.
But now I intent to transform the macro using the function COUNT,
Sub C_m()
Range("H6").Select
ActiveCell.Formula = "=COUNT(B:B)"
End Sub
BUT then, I realize my logic do not worked as before, the only thing
So far, I can see is, must be a loop, how I will deduce that?, “ I don’t know” that why I am here.
Thank you.
I am here trying to see the transformation from a simple Macro to a Code, I know guy for you is something so Simple, but “ sorry “ no for me, I am a new self-thaught bee.
I just sum two numbers with the macro recorder I got this:
Range("H2").Select
ActiveCell.Formula = "=SUM(A2:B2)"
So with my Basic knowledge I see that H2 has to be a variable, sum I can think as a total, or another variable, and the two location as well, so I got this:
Sub real_code()
Dim H As Integer, A As Integer, B As Integer
A = Range("A2").Value: B = Range("B2").Value
H = A + B
Range("H1").Value = H
End Sub
And “”Bingo”” work well.
But now I intent to transform the macro using the function COUNT,
Sub C_m()
Range("H6").Select
ActiveCell.Formula = "=COUNT(B:B)"
End Sub
BUT then, I realize my logic do not worked as before, the only thing
So far, I can see is, must be a loop, how I will deduce that?, “ I don’t know” that why I am here.
Thank you.