R/T Error encounter - Posted originally to functions ng - in error

J

Jim May

Sub SumByEmployee()
Dim MyPick As String
Dim mTotal As Double
Dim rngemp As Range
mTotal = 0
MyPick = InputBox("What Employee Do you Want?")
Set rngemp = Range("C6:C15") 'list of employees - single names
For Each c In rngemp
If c = MyPick Then
mTotal = mTotal + rngemp.Offset(, -1).Value 'R/T error happens here
End If
Next c
Range("B18").Value = mTotal
End Sub

Thanks for any help!!
 
D

Don Guillett

try this simpler version

Sub SumByEmployee()
MyPick = InputBox("What Employee Do you Want?")
For Each c In Range("C6:C15")
If c = MyPick Then mTotal = mTotal + c.Offset(, -1)
Next c
Range("B18") = mTotal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top