Zachary902
New Member
- Joined
- Nov 5, 2013
- Messages
- 7
The code below automatically calls AddHeaderHours when something is entered into cell G30, this code does work (coded to the worksheet).
The line of code that is surrounded by stars gives me the error "Run-time error '5': invalid procedure call or argument". I have been tinkering with it for a while and not sure how to fix it or what it really means. If you see any other little mistakes point them out. Im still sorta new to VBA.
Thanks,
Code:
'---------------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$G$30" Then
Call AddHeaderHours
End If
End Sub
'-----------------------------------------------------------------------
'----------------------------------------------------------------------
Sub AddHeaderHours()
Dim MonthName As String
Dim CropName As String
Dim CurrentHrs As Integer
Dim DailyHrs As Integer
Dim Rng1 As Range
Dim Rng2 As Range
Dim isect As Range
Workbook("278DH## Daily Report Template").Activate
Workbook("278DH## Daily Report Template").Worksheets("278DH## Daily Summary").Select
MonthName = Range("E2")
CropName = Range("E13")
Sheets("Crop Hours Log").Select
Select Case CropName
Case "Wheat"
Set Rng1 = Range("E3:E14")
End Select
Select Case MonthName
Case "February"
Set Rng2 = Range("E4:AP4")
End Select
' ***Set isect = Application.Intersect(Rng1, Rng2)***
isect.Value = CurrentHrs
Range("G30").Select
Selection = DailyHrs
CurrentHrs = CurrentHrs + DailyHrs
Application.Intersect(Rng1, Rng2).Select
Selection.Paste
End Sub
'-------------------------------------------------------------------
The line of code that is surrounded by stars gives me the error "Run-time error '5': invalid procedure call or argument". I have been tinkering with it for a while and not sure how to fix it or what it really means. If you see any other little mistakes point them out. Im still sorta new to VBA.
Thanks,
Last edited by a moderator: