adapting some code

rhino4eva

Active Member
Joined
Apr 1, 2009
Messages
262
Office Version
  1. 2010
Platform
  1. Windows
Code:
Sub punchclock()
    Dim ws As Worksheet
    Dim rFound As Range
    datenow = Format(Now(), "ddd dd")
    timenow = Format(Now(), "hh:mm")
    Set ws = Sheets("Sheet1")
    With ws.Range("c1:f33")
        On Error Resume Next
        Set rFound = .Find("*", SearchDirection:=xlPrevious, SearchOrder:=xlByColumns, LookIn:=xlValues)
        On Error GoTo 0
        If rFound Is Nothing Then
        .Cells(1).Value = timenow
        ElseIf Intersect(rFound, .Cells(.Rows.Count, .Columns.Count)) Is Nothing Then
            If rFound.Row < .Rows(.Rows.Count).Row Then
                rFound.Offset(1, 0).Value = timenow
            Else
                rFound.Offset(.Rows.Count + 1, 1).Value = timenow
            End If
        Else
            MsgBox "No empty cell found within " & .Address(0, 0) & ".", vbInformation
        End If
    End With
End Sub

I am trying modify some code that a fellow Mr excel forum user gave me
I have got it to add a time stamp every time it's run in to the next empty cell in column as it goes down from c1 to c33 then back up to d2 down to d33 etc.

my problem is two fold

1)How do I make go across 4 columns and then go onto the next row.
2)I have set a datenow variable in the hope I will be able search down column b and start the time stamping in in columns c,d,e,f

any help would be gratefully received
 
Last edited by a moderator:

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top