VBA- Rounding a static value to closest increment of a Loop/Array created from another static value

shazbatz

New Member
Joined
Nov 25, 2018
Messages
3
[TABLE="width: 500"]
<tbody>[TR]
[TD]INCREMENT[/TD]
[TD]STATIC 1[/TD]
[TD]STATIC 2[/TD]
[TD]VALUE[/TD]
[/TR]
[TR]
[TD].25
[/TD]
[TD]100[/TD]
[TD]100.35[/TD]
[TD][/TD]
[/TR]
[TR]
[TD].45[/TD]
[TD]200[/TD]
[TD]201.55[/TD]
[TD][/TD]
[/TR]
[TR]
[TD].65[/TD]
[TD]300[/TD]
[TD]302.75[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

I'm struggling to figure out in VBA the most efficient way to create a loop/array within the value in the STATIC 1 column using the increment in same row, and then rounding the STATIC 2 value in same row to nearest element within the loop/array to derive the desired VALUE in blank column.

Example loop/array for first row with .25 increment and 100:
99.25 99.50 99.75 100 100.25 100.50 100.75

Rounding the 100.35 to nearest element of 100.25, thus making 100.25 the desired value in blank cell

And so on for additional rows creating the loops/arrays based on coinciding increments
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Here's a worksheet formula (which can be entered in the VALUE column with a macro if required) :

=B2+(A2*ROUND((C2-B2)/A2,0))
 
Upvote 0
Here's a worksheet formula (which can be entered in the VALUE column with a macro if required) :

=B2+(A2*ROUND((C2-B2)/A2,0))
That worked perfectly. Thank you

What if the values in column C are not static? Can a formula be utilized to capture the non-static value at a specific time using the Windows clock time?
 
Upvote 0
What if the values in column C are not static? Can a formula be utilized to capture the non-static value at a specific time using the Windows clock time?

Provided you have calculations set to automatic, the formula will automatically account for any changes in column C.
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,250
Members
452,623
Latest member
Techenthusiast

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top