Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 211
Default Macro, how to set a cell value to zero

I am a newbie in VBA.
I want to set a cell value to zero after For and before Set statement in the
following MAcro. How can I do that.

Sub RoundToZero1()
For Counter = 1 To 12
Set curCell = Worksheets("Sheet1").Cells(Counter, 3)
If Abs(curCell.Value) < 0.5 Then Cells(Counter, 4) = "These numbers
are lass than 0.5"
Next Counter
End Sub

--
R. Khoshravan
Please click "Yes" if it is helpful.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Macro, how to set a cell value to zero

You can just use the
Worksheets("Sheet1").Cells(row,col).Value=0 statement to set the cell value
to zero.


#
Sub RoundToZero1()
For Counter = 1 To 12

Worksheets("Sheet1").Cells(Counter, 3).Value=0

Set curCell = Worksheets("Sheet1").Cells(Counter, 3)
If Abs(curCell.Value) < 0.5 Then Cells(Counter, 4) = "These numbers
are lass than 0.5"
Next Counter
End Sub
#


Hope this works

Have a nice time

Chris
------
Convert your Excel spreadsheet into an online calculator.
http://www.spreadsheetconverter.com

--
Message posted via http://www.officekb.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 211
Default Macro, how to set a cell value to zero

Thanks for your comment.
Isn't it possible to eliminate the first part:
Worksheets("Sheet1").

--
R. Khoshravan
Please click "Yes" if it is helpful.


"Chris Bode via OfficeKB.com" wrote:

You can just use the
Worksheets("Sheet1").Cells(row,col).Value=0 statement to set the cell value
to zero.


#
Sub RoundToZero1()
For Counter = 1 To 12

Worksheets("Sheet1").Cells(Counter, 3).Value=0

Set curCell = Worksheets("Sheet1").Cells(Counter, 3)
If Abs(curCell.Value) < 0.5 Then Cells(Counter, 4) = "These numbers
are lass than 0.5"
Next Counter
End Sub
#


Hope this works

Have a nice time

Chris
------
Convert your Excel spreadsheet into an online calculator.
http://www.spreadsheetconverter.com

--
Message posted via http://www.officekb.com


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
'IF' Macro to insert cell contents to alternate cell if cell not e Gryndar Excel Worksheet Functions 6 December 20th 08 05:02 PM
using a cell value to control a counter inside a macro and displaying macro value ocset Excel Worksheet Functions 1 September 10th 06 05:32 AM
If cell is empty then run macro otherwise skip this macro [email protected] Excel Programming 3 June 12th 06 03:55 PM
macro to run a separate macro dependent on value in cell scottwilsonx[_13_] Excel Programming 3 July 26th 04 02:30 PM
Question: Cell formula or macro to write result of one cell to another cell Frederik Romanov Excel Programming 1 July 8th 03 03:03 PM


All times are GMT +1. The time now is 11:50 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"