Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default automatic counting

I have a cell which has a number entered into it. I want to be able to use a
different cell to count upto that cell at the press of a key command... is
this possible?

example:


cell A1 = 12
Cell A2 should read cell A1 and count from 1 to 12 after a key command
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default automatic counting

Add a form control button and assign the macro 'Count' to it.

Then add this code into a standard module, the line Sleep 1000 delays the
update by 1000 milli seconds, change this as required...

Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub Count()
Dim iC As Long
With ActiveSheet
For iC = 1 To .Range("A1")
Sleep 1000
.Range("A2") = iC
Next
End With
End Sub

--

Regards,
Nigel




"neilb" wrote in message
...
I have a cell which has a number entered into it. I want to be able to use
a
different cell to count upto that cell at the press of a key command... is
this possible?

example:


cell A1 = 12
Cell A2 should read cell A1 and count from 1 to 12 after a key command


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default automatic counting

Put this is a standard code module

Public nTick As Long

Public Sub CountDown()

With Range("A2")

.Value = .Value + 1
If .Value < nTick Then

Application.OnTime Now() + TimeSerial(0, 0, 1), "CountDown"
End If
End With

End Sub


Then add this to the worksheet code module

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target

If IsNumeric(.Value) Then

nTick = .Value
.Offset(1, 0).Value = 0
Call CountDown
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"neilb" wrote in message
...
I have a cell which has a number entered into it. I want to be able to use
a
different cell to count upto that cell at the press of a key command... is
this possible?

example:


cell A1 = 12
Cell A2 should read cell A1 and count from 1 to 12 after a key command



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
Automatic Letter Counting Kcope8302 Excel Discussion (Misc queries) 0 February 10th 09 08:03 PM
Automatic update of spreadsheet & automatic update between workboo Losva Excel Worksheet Functions 6 September 12th 08 03:22 PM
counting function but not double counting duplicates JRD Excel Worksheet Functions 2 November 7th 07 06:43 PM
Counting rows, then counting values. Michael via OfficeKB.com Excel Discussion (Misc queries) 7 August 4th 05 10:57 PM
Counting Rows Then Counting Values in Columns Michael via OfficeKB.com Excel Programming 1 June 1st 05 04:10 PM


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