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
INCREMENTSTATIC 1STATIC 2VALUE
.25
100100.35
.45200201.55
.65300302.75

<tbody>
</tbody>

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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
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,214,911
Messages
6,122,194
Members
449,072
Latest member
DW Draft

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