Results 1 to 6 of 6

Object Issue

Threaded View

darbar82 Object Issue 06-15-2013, 11:15 PM
MarvinP Re: Object Issue 06-15-2013, 11:26 PM
darbar82 Re: Object Issue 06-16-2013, 03:32 AM
abousetta Re: Object Issue 06-16-2013, 12:38 AM
darbar82 Re: Object Issue 06-16-2013, 03:33 AM
abousetta Re: Object Issue 06-16-2013, 05:16 AM
  1. #1
    Registered User
    Join Date
    04-01-2013
    Location
    Hong Kong
    MS-Off Ver
    Excel 2010
    Posts
    14

    Object Issue

    Hi,

    Think i have an object issue below as the loop code previously worked. i've attached a word document showing the screen print and have scoured the internet but simply cannot remove the error
    The CurrentMth Value shows up as teh correct string when i hover above it.
    Any pointers appreciated

    Sub AddOvertimeInfo()
    
    ' Add the overtime hours worked in the relevant month to table for payroll submission
        
    Dim CurrentMth As String
    CurrentMth = ActiveWorkbook.Sheets("Data Sheet").Range("C3").Value
    Dim TargetWS As Worksheet
    TargetWS = ActiveWorkbook.Sheets(CurrentMth)
    Dim ExportWS As Worksheet
    ExportWS = ActiveWorkbook.Sheets("Export LLR")              ' may be able to make this more flexible
    
    Dim EmployeeName As Range
    EmployeeName = TargetWS.Rows("2:2")                         ' may be able to make this more flexible
    Dim TotalOvertime As Range
    TotalOvertime = TargetWS.Rows("37:37")                      ' may be able to make this more flexible
    Dim TotalOnCallHours As Range
    TotalOnCallHours = TargetWS.Rows("40:40")                   ' may be able to make this more flexible
    Dim EmpNme As String
    Dim Counter As Integer
    Dim LastRow As Long
                                                                                                          
                                                                      
    ' this is the loop for adding the overtime hours & on call days
        
        Counter = 5                            ' this is the starting line in the export sheet
        LastRow = WorksheetFunction.Match("Total", ExportWS.Columns("A:A"), 0)
          
          Do
            EmpNme = Cells(Counter, "B") & " " & Cells(Counter, "C")
            ExportWS.Cells(Counter, "H").Value = Application.WorksheetFunction.SumIf(EmployeeName, EmpNme, TotalOvertime)
            ExportWS.Cells(Counter, "J").Value = Application.WorksheetFunction.SumIf(EmployeeName, EmpNme, TotalOnCallHours)
            Counter = Counter + 1
            
            Loop Until Counter = LastRow
    
    End Sub
    Attached Files Attached Files
    Last edited by Leith Ross; 06-16-2013 at 12:36 AM. Reason: Added Code Tags

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