PC Review


Reply
Thread Tools Rate Thread

automatic counting

 
 
neilb
Guest
Posts: n/a
 
      9th Aug 2008
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 With Quote
 
 
 
 
Nigel
Guest
Posts: n/a
 
      9th Aug 2008
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
(E-Mail Removed)



"neilb" <(E-Mail Removed)> wrote in message
news:8BB62B7F-0D32-4FA9-B017-(E-Mail Removed)...
>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 With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      9th Aug 2008
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" <(E-Mail Removed)> wrote in message
news:8BB62B7F-0D32-4FA9-B017-(E-Mail Removed)...
>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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic Letter Counting Kcope8302 Microsoft Excel Misc 0 10th Feb 2009 08:03 PM
counting function but not double counting duplicates =?Utf-8?B?SlJE?= Microsoft Excel Worksheet Functions 2 7th Nov 2007 06:43 PM
Counting rows, then counting values. Michael via OfficeKB.com Microsoft Excel Misc 7 4th Aug 2005 10:57 PM
Counting Rows Then Counting Values in Columns Michael via OfficeKB.com Microsoft Excel Programming 1 1st Jun 2005 04:10 PM
12,000 and counting - dead, 1 Million and counting - homeless David Candy Windows XP General 34 1st Jan 2005 10:27 PM


Features
 

Advertising
 

Newsgroups
 


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