erikalcala
New Member
- Joined
- Jan 19, 2017
- Messages
- 3
Hi, I've been looking how I could populate a range with a vba expression but I haven't had any success, I've checked the sections on loops and arrays but I can't come up with a solution
Any help would be much appreciated, I wish I could populate a specific range lets say N10:N50 with values starting from X and ending in Y but with a step constraint
I tried this with no success
Any help would be much appreciated, I wish I could populate a specific range lets say N10:N50 with values starting from X and ending in Y but with a step constraint
I tried this with no success
Code:
[FONT=monospace]'create the array[/FONT]
[FONT=monospace]Dim Tvect As Variant[/FONT]
[FONT=monospace]Dim Trange As Range[/FONT]
[FONT=monospace]Dim countvar As Integer[/FONT]
[FONT=monospace]Tstep = 50[/FONT]
[FONT=monospace]countvar = Range("N10").Value 'the value of the cell N10[/FONT]
[FONT=monospace]For countvar = X To Y [/FONT]
[FONT=monospace]Range("N10" & countvar).Value = countvar + Tstep 'starting from N10 and downwards[/FONT]
[FONT=monospace]Next countvar[/FONT]
[FONT=monospace]'writing to worksheet[/FONT]
[FONT=monospace]'Set Trange = Range("M10")[/FONT]
[FONT=monospace]'Set Trange = Prange.Resize(UBound(Tvect), 1)[/FONT]
[FONT=monospace]'Trange .Value = Application.Transpose(Tvect)[/FONT][COLOR=#333333]
[/COLOR]