Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
big stupid question Wu Excel Discussion (Misc queries) 4 May 17th 08 05:33 PM
Stupid Question Justin Kreamer Excel Discussion (Misc queries) 1 May 2nd 08 07:47 AM
stupid question Kimberly New Users to Excel 4 May 18th 07 08:55 PM
Stupid Question mastermind Excel Worksheet Functions 1 August 5th 06 07:03 PM
Stupid, stupid question.... DS Excel Programming 3 September 25th 05 03:51 PM


All times are GMT +1. The time now is 05:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"