Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
stupid round question
Hi! I have been using round function a lot in worksheets. But now I am
writing a macro and want to select a column and then round all of the numbers in it. For some reason, no metter what I do, I can not seem to figure out how to do that... Any suggestions? -- Sergei D |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
stupid round question
To Format a column to 2 d.p
:======================= Sub RoundColumn() Columns("A:A").NumberFormat = "#,##0.00" End Sub :======================= To round each value in a selection to 2 d p :======================= Sub RoundColumnValue() Dim cl As Range For Each cl In Selection cl.Value = Application.WorksheetFunction.Round(cl.Value, 2) Next cl End Sub :===================== http://www.excel-ant.co.uk |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
stupid round question
cells(1,1).value = Round (cells(1,1).value)
HTH -- AP "Sergei D" a écrit dans le message de news: ... Hi! I have been using round function a lot in worksheets. But now I am writing a macro and want to select a column and then round all of the numbers in it. For some reason, no metter what I do, I can not seem to figure out how to do that... Any suggestions? -- Sergei D |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
stupid round question
this is great... but how can I appy it to the whole column?
-- Sergei D "Ardus Petus" wrote: cells(1,1).value = Round (cells(1,1).value) HTH -- AP "Sergei D" a écrit dans le message de news: ... Hi! I have been using round function a lot in worksheets. But now I am writing a macro and want to select a column and then round all of the numbers in it. For some reason, no metter what I do, I can not seem to figure out how to do that... Any suggestions? -- Sergei D |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
stupid round question
this seems logical and should work. But.. i get: "object variable or with
object variable not set" error message. -- Sergei D "somethinglikeant" wrote: To Format a column to 2 d.p :======================= Sub RoundColumn() Columns("A:A").NumberFormat = "#,##0.00" End Sub :======================= To round each value in a selection to 2 d p :======================= Sub RoundColumnValue() Dim cl As Range For Each cl In Selection cl.Value = Application.WorksheetFunction.Round(cl.Value, 2) Next cl End Sub :===================== http://www.excel-ant.co.uk |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
stupid round question
actually.. I got it working. Thanks.
cl does not stand for cell???.. because when I changed to cl it began to work...again. thanks -- Sergei D "somethinglikeant" wrote: To Format a column to 2 d.p :======================= Sub RoundColumn() Columns("A:A").NumberFormat = "#,##0.00" End Sub :======================= To round each value in a selection to 2 d p :======================= Sub RoundColumnValue() Dim cl As Range For Each cl In Selection cl.Value = Application.WorksheetFunction.Round(cl.Value, 2) Next cl End Sub :===================== http://www.excel-ant.co.uk |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
big stupid question | Excel Discussion (Misc queries) | |||
Stupid Question | Excel Discussion (Misc queries) | |||
stupid question | New Users to Excel | |||
Stupid Question | Excel Worksheet Functions | |||
Stupid, stupid question.... | Excel Programming |