combine ranges into one peice of code create error message for rounding code

Mikeymike_W

Board Regular
Joined
Feb 25, 2016
Messages
171
Hi All,

I have the following piece of code that will round value (positive and negative values) to the nearest 0.5:

For i = 33 To 35
With Sheets(1).Cells(i, 14)
If .Value <> "" Then
.Value = Application.MRound(.Value, Sgn(.Value) * 0.5)
End If
End With
Next
For i = 12 To 21
With Sheets(1).Cells(i, 17)
If .Value <> "" Then
.Value = Application.MRound(.Value, Sgn(.Value) * 0.5)
End If
End With
Next

For i = 12 To 24
With Sheets(1).Cells(i, 19)
If .Value <> "" Then
.Value = Application.MRound(.Value, Sgn(.Value) * 0.5)
End If
End With
Next


I have it set up for a few different cell ranges so I have two question:

1) is it possible to combine these rather than having multiples

2) I want to have an error that appears so if a user enters a range of values into the cell (17-25 for example)
they are prompted to enter a single number and when they select OK the cell will be reselected

I hope you are able to help out.

Thanks in advance,

Mike
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,214,584
Messages
6,120,385
Members
448,956
Latest member
JPav

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