ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro Code required (https://www.excelbanter.com/excel-discussion-misc-queries/185225-macro-code-required.html)

muddan madhu

Macro Code required
 
Hi,

I have a macro to calculate the time ...
Col A - Start time
Col B - End Time

click Button created -e.g., if user click that buttton it gives the
system time as 00:06:53 in A1 (hh:mm:ss) and again
if user click that button it will gives the system 00:06:55 in
B1.... if user click that button again it moves to A2 and gives the
times...
similarly it moves down as and when user clicks..

The problem is user chooses different cells, so this lead wrong time
calculation so i need to specify the range as (B10:C100). so that the
time will
calculate in right manner.

Thanks a lot

Earl Kiosterud

Macro Code required
 
Muddan,

Dim Coll As Integer
Dim Roww As Integer

Sub TimeReset()
Coll = 1
Roww = 1
End Sub

Sub TimeInsert()
If Roww = 0 Or Coll = 0 Then TimeReset
Cells(Coll, Roww) = Time()
If Roww = 1 Then
Roww = Roww + 1
Else
Roww = 1
Coll = Coll + 1
End If
End Sub

--
Regards from Virginia Beach,

Earl Kiosterud
www.smokeylake.com
-----------------------------------------------------------------------
"muddan madhu" wrote in message
...
Hi,

I have a macro to calculate the time ...
Col A - Start time
Col B - End Time

click Button created -e.g., if user click that buttton it gives the
system time as 00:06:53 in A1 (hh:mm:ss) and again
if user click that button it will gives the system 00:06:55 in
B1.... if user click that button again it moves to A2 and gives the
times...
similarly it moves down as and when user clicks..

The problem is user chooses different cells, so this lead wrong time
calculation so i need to specify the range as (B10:C100). so that the
time will
calculate in right manner.

Thanks a lot





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

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