Excel VBA

Solved/Closed
ugo234 Posts 5 Registration date Tuesday 15 October 2013 Status Member Last seen 24 October 2013 - 15 Oct 2013 à 10:50
ugo234 Posts 5 Registration date Tuesday 15 October 2013 Status Member Last seen 24 October 2013 - 24 Oct 2013 à 08:37
Hi all,

Greetings, could I get help, I am trying to write data into cells in a spread sheet, using an initial value, then adding a specific increment until it reaches a maximum value also specified. I have included an example below. Thank you.

Min: 0.5
Max: 1.5
Increment: 0.1
Related:

4 responses

TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 555
15 Oct 2013 à 11:30
Hi Ugo,

Put your min value in A1, max in A2 and increment in A3.
Use the code below to get result in column B:

Sub RunMe()
Dim iMin, iMax, iIcr, x As Currency

iMin = Range("A1").Value
iMax = Range("A2").Value
iIcr = Range("A3").Value

Range("B1").Value = iMin
x = 1

Do
x = x + 1
Range("B" & x).Value = Range("B" & x - 1).Value + iIcr
Loop Until Range("B" & x).Value = iMax

End Sub

Best regards,
Trowa
ugo234 Posts 5 Registration date Tuesday 15 October 2013 Status Member Last seen 24 October 2013
15 Oct 2013 à 12:07
Hi Trowa,

Thanks for taking out the time to help.. I ran the macro, and it basically filled the whole sheet down to the last row. I tried to modify it, but unfortunately, I have only been at VBA for a short while. Could I ask for more assistance please... Cheers once more...


Kind Regards

Ugo
ugo234 Posts 5 Registration date Tuesday 15 October 2013 Status Member Last seen 24 October 2013
15 Oct 2013 à 12:06
Hi Trowa,

Thanks for taking out the time to help.. I ran the macro, and it basically filled the whole sheet down to the last row. I tried to modify it, but unfortunately, I have only been at VBA for a short while. Could I ask for more assistance please... Cheers once more...


Kind Regards

Ugo
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 555
17 Oct 2013 à 10:30
Hi Ugo,

Strange, it works for me.
Please check your cell references as well as your inputted values.

You can also check the following file, run the code and see if there is a difference:
http://speedy.sh/HZtFK/Ugo-Excel-VBA.xls

Best regards,
Trowa
ugo234 Posts 5 Registration date Tuesday 15 October 2013 Status Member Last seen 24 October 2013
24 Oct 2013 à 08:37
Hi Trowa,


Sorry took so long to reply. worked well, I just added > before the = sign, and although it gives just one value greater, I am fine with it.. no worries at all.. Thanks a lot for the assistance. Cheers

Regards

Ugo