Excel VBA

Solved/Closed
ugo234 Posts 5 Registration date Tuesday October 15, 2013 Status Member Last seen October 24, 2013 - Oct 15, 2013 at 10:50 AM
ugo234 Posts 5 Registration date Tuesday October 15, 2013 Status Member Last seen October 24, 2013 - Oct 24, 2013 at 08:37 AM
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 September 12, 2010 Status Moderator Last seen December 27, 2022 552
Oct 15, 2013 at 11:30 AM
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 October 15, 2013 Status Member Last seen October 24, 2013
Oct 15, 2013 at 12:07 PM
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
0
ugo234 Posts 5 Registration date Tuesday October 15, 2013 Status Member Last seen October 24, 2013
Oct 15, 2013 at 12:06 PM
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 September 12, 2010 Status Moderator Last seen December 27, 2022 552
Oct 17, 2013 at 10:30 AM
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 October 15, 2013 Status Member Last seen October 24, 2013
Oct 24, 2013 at 08:37 AM
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