Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Round Row Values in Excel Using VBA 1

Status
Not open for further replies.

cghoga

Programmer
Jun 26, 2003
614
US
We have a simple timesheet in Excel.

We are sticking with Excel period.

Within the 'Hours' column, if someone enters 1.15 I want it to round to the nearest .25.

I found the following formula that I use on a my spreadsheet and it works fine.

ROUND(A1/.25,0)*.25

I am trying to incorporate this into VBA so that when the employee clicks a Submit button it rounds the value(s) for them.

I have the following code:

For Counter = 1 To 100
Set curCell = Worksheets("Project List").Cells(Counter, 5)Cells(curCell) = Round(Cells(curCell).Value / 0.25, 0) * 0.25

I may be making this too hard, I may be making this too simple.

If this post is too vague, my apologies, please let me know and I will provide more background.

Thanks.
 
Just this should do it:

Code:
Set curCell = Worksheets("Project List").Cells(Counter, 5).Value 
   curCell.Value = Round(curCell.Value / 0.25, 0) * 0.25

Cheers,

Roel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top