Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default adding to a cell in excel


i want a cell to automatically increase its value by 1 each time another
(predetermined) cell shows a value of zero, is this possible ?, if so,
how would i go about it ?.


--
dadad
------------------------------------------------------------------------
dadad's Profile: http://www.excelforum.com/member.php...o&userid=16712
View this thread: http://www.excelforum.com/showthread...hreadid=320480

  #2   Report Post  
Posted to microsoft.public.excel.programming
N10 N10 is offline
external usenet poster
 
Posts: 141
Default adding to a cell in excel


"dadad" wrote in message
...

i want a cell to automatically increase its value by 1 each time another
(predetermined) cell shows a value of zero, is this possible ?, if so,
how would i go about it ?.


--
dadad
------------------------------------------------------------------------
dadad's Profile:
http://www.excelforum.com/member.php...o&userid=16712
View this thread: http://www.excelforum.com/showthread...hreadid=320480


HI

Here is a simple but effective demo of some code which might assist you

Sub ADJUSTCELL()

Dim inc As Integer

Range("a1") = ""
Range("b1") = ""

For x = 1 To 1000
Range("b1") = Int(Rnd() * 1000)
If Range("b1") = 0 Then inc = inc + 1


Range("a1") = inc

Next

End Sub


Best N10 Beginner



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default adding to a cell in excel

This code should be just about plug and play. I assume you can get int the
VBA window (Alt F11). Paste this code into the sheet you want to increment.
You will need to fix the cell references in this code. "$A$2" where you are
testing for 0 and ("B2") where you are incrementing the result...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$2" And Target.Value = 0 Then
Sheets("Sheet1").Range("B2") = Sheets("Sheet1").Range("B2") + 1
End If
End Sub

If you need more help just ask...

"dadad" wrote:


i want a cell to automatically increase its value by 1 each time another
(predetermined) cell shows a value of zero, is this possible ?, if so,
how would i go about it ?.


--
dadad
------------------------------------------------------------------------
dadad's Profile: http://www.excelforum.com/member.php...o&userid=16712
View this thread: http://www.excelforum.com/showthread...hreadid=320480


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default adding to a cell in excel

dadad wrote:
i want a cell to automatically increase its value by 1 each time another
(predetermined) cell shows a value of zero, is this possible ?, if so,
how would i go about it ?.


'each time' needs narrowing --
'each recalculation' or 'each time any data is entered' or
'each time a1 goes from non-zero to zero' or ..
This assumes B1 gets incremented when 0 is entered into A1:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not (Intersect(Range("a1"), Target) Is Nothing) Then
If IsNumeric(Range("a1")) Then
If Cells(1, 1) = 0 Then Cells(1, 2) = Cells(1, 2) + 1
End If
End If
End Sub
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
how to format a cell adding 17.5% VAT excel The Red Devil Excel Discussion (Misc queries) 2 January 24th 07 09:24 PM
Can I split a excel cell w/out adding a column? Cheryl Excel Discussion (Misc queries) 1 April 19th 06 04:22 PM
Adding footnote to cell in Excel Tom B Excel Discussion (Misc queries) 1 February 17th 06 09:29 PM
formula for adding every other cell in Excel Michelle Odell Excel Worksheet Functions 2 January 23rd 06 05:30 PM
adding a command button to an excel cell? betelguese Excel Discussion (Misc queries) 1 March 22nd 05 03:09 AM


All times are GMT +1. The time now is 01:20 PM.

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

About Us

"It's about Microsoft Excel"