Excel VBA [Solved/Closed]

Report
Posts
5
Registration date
Tuesday October 15, 2013
Status
Member
Last seen
October 24, 2013
-
Posts
5
Registration date
Tuesday October 15, 2013
Status
Member
Last seen
October 24, 2013
-
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

4 replies

Posts
2674
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
October 27, 2020
446
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
Posts
5
Registration date
Tuesday October 15, 2013
Status
Member
Last seen
October 24, 2013

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
Posts
5
Registration date
Tuesday October 15, 2013
Status
Member
Last seen
October 24, 2013

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
Posts
2674
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
October 27, 2020
446
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
Posts
5
Registration date
Tuesday October 15, 2013
Status
Member
Last seen
October 24, 2013

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