ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Syntax to set cells to be zero (https://www.excelbanter.com/excel-discussion-misc-queries/42766-syntax-set-cells-zero.html)

chermaine

Syntax to set cells to be zero
 
Actually i have created a button for retreiving teh data (numerical
figure) from one worksheet to another worksheet but that requires some
addition and subtraction on the original value. I now would like to
make every "to be filled cells" to be "zero" which can help me to do
the subtraction later on. So I wonder if there is anyone can teach me
some the syntax for that operation. ( i would like to make a button to
set those cells zero first) Anyone please help!


Dave O

Good morning, Chermaine-
Just to make sure I understand: you have a "Source" spreadsheet, and
you've written some code to pull data from the Source and write it to a
"Target" spreadsheet. But due to the nature of your application you
first need to set the Target cells to have a zero value before any of
this operation occurs. Is that about right?

I'm curious about the need to have a zero value inserted into the
target cells, because empty cells have effectively a zero value by
default. If you need those cells to *display* a zero value, you can
set that in advance using cell formatting. If you need to subtract
something from zero, you might instead multiply by -1.

To answer your question, the syntax to set a cell to zero is
ActiveCell.Value = 0
....which may or may not apply to your situation, because you may need
to set an entire range to zero. You may be able to have this or
similar code run in your existing macro; just place this code in such a
way as to run first, before the data retrieval code.



All times are GMT +1. The time now is 07:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com