Results 1 to 1 of 1

Fill cells determined by Time Value selection w/user form

Threaded View

ShannonHowell Fill cells determined by Time... 10-12-2012, 09:56 PM
  1. #1
    Registered User
    Join Date
    12-09-2011
    Location
    Eureka, CA
    MS-Off Ver
    Excel 2010
    Posts
    22

    Fill cells determined by Time Value selection w/user form

    Hi everyone,

    I use a spreadsheet to check my staff's time cards. I use a grid with dates in the top row and the time by 30 minute increments in the first column(actually second column (B) but it is the first column with any data). I fill in names of the staff across the grid to represent the hours they have claimed on their time sheets. This way i can easily see if 2 people have double claimed hours or if hours haven't been claimed at all.

    I use the following code(which i got from this forum @ http://www.excelforum.com/excel-prog...-formulas.html) to find the start and end times for each person and sort them into easy to read tables. Unfortunately I don't really understand this code. What I actually would like is code that would do the opposite of this.

    I would like to use a user-form to have my management staff enter in the time in a traditional manner (Pick staff name, Pick start date and time and end date and time from combo boxes) and have it fill in the grid accordingly. The code would need to alert the user when hours have been double claimed and also if at the end of entering all the time cards if hours have been unclaimed. I hope my request is intelligable, i'm pretty sure it's possible but haven't got a clue where to start. Thanks in advance for the help guys

    For TF = 1 To 20   'TF limit can be changed dpending on requirement.
                      'one blank column is must for each table in Result sheet
    Fval = Range("B53").Offset(TF - 1, 0).Value
    Sheets("Result").Range(Cells(3, 1 + (TF - 1) * 5).Address, Cells(60, 3 + (TF - 1) * 5).Address).ClearContents
        
        For Tcol = 3 To Range("B2").End(xlToRight).Column
            For TRow = 3 To 50
            
            If Sheets("Result").Cells(3, 1 + (TF - 1) * 5) = "" Then
            Pro = 3
            Else
            Pro = Sheets("Result").Cells(2, 1 + (TF - 1) * 5).End(xlDown).Row + 1
            End If
            
            If Cells(TRow, Tcol) = Fval Then
                If Cells(TRow - 1, Tcol) <> Fval Then
                Sheets("Result").Cells(Pro, 2 + (TF - 1) * 5) = Cells(TRow, 2)
                ElseIf Cells(TRow + 1, Tcol) <> Fval Then
                Sheets("Result").Cells(Pro, 3 + (TF - 1) * 5) = Cells(TRow, 2) + TimeValue("00:30:00")
                Sheets("Result").Cells(Pro, 1 + (TF - 1) * 5) = Cells(1, Tcol)
                End If
            End If
            
            Next TRow
        Next Tcol
    Next TF
    
        
        Sheets("Tables").Select
        
        For lngMyCol = 1 To Cells.Find("*", searchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column Step 6
        
            strColFrom = Left(Cells(1, lngMyCol).Address(True, False), Application.WorksheetFunction.Search("$", Cells(1, lngMyCol).Address(True, False)) - 1)
            strColTo = Left(Cells(1, lngMyCol + 4).Address(True, False), Application.WorksheetFunction.Search("$", Cells(1, lngMyCol + 4).Address(True, False)) - 1)
            
            For Each rngCell In Range(strColFrom & "2:" & strColFrom & Range(strColFrom & ":" & strColTo).Find("*", searchOrder:=xlByRows, SearchDirection:=xlPrevious).Row)
                If Evaluate("COUNT(" & strColFrom & rngCell.Row & ":" & strColTo & rngCell.Row & ")") > 0 Then
                    If WorksheetFunction.CountA(Sheets("CSV").Cells) = 0 Then
                        Sheets("CSV").Range("A2:E2").Value = Range(strColTo & rngCell.Row & ":" & strColFrom & rngCell.Row).Value 'Default if there's no data in the 'CSV' tab.
                    Else
                        lngMyRow = Sheets("CSV").Range("A:E").Find("*", searchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
                        Sheets("CSV").Range("A" & lngMyRow & ":E" & lngMyRow).Value = Range(strColFrom & rngCell.Row & ":" & strColTo & rngCell.Row).Value 'Default if there's no data in the 'CSV' tab.
                    End If
                End If
            Next rngCell
                
        Next lngMyCol
        
        With Sheets("CSV")
            .Select
            Columns("A:E").EntireColumn.AutoFit
        End With
    Attached Files Attached Files
    Last edited by ShannonHowell; 10-13-2012 at 02:35 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1