Macro, how to set a cell value to zero

K

Khoshravan

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
 
C

Chris Bode via OfficeKB.com

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
 
K

Khoshravan

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top