Hello all,
Can anyone tell me what my error is? It says "Type Mismatch" and stops on the line "ActCode = Application.VLookup(day, Sheet2.Range("H8:H41"), Sheet2.Range("A8:A41"), True)"
This code is supposed to take numerical value "day", find the closest match (not exact) in Sheet2.Range("H8:H41"), and return the corresponding text (string) from Sheet2.Range("A8:A41") saved as ActCode.
Option Explicit
Sub Filldata()
Dim TDHT As Double
TDHT = Sheet2.Cells(43, 8).Value
Dim i As Integer
For i = 1 To TDHT
Dim ActCode As String
Dim day As Double
day = Sheet3.Cells(10, 4 + i).Value
ActCode = Application.WorksheetFunction.VLookup(day, Sheet2.Range("H8:H41,A8:A41"), Sheet2.Range("A8:A41"), True)
Sheet3.Cells(11, 4 + i).Value = ActCode
Next i
End Sub
Any help would be greatly appreciated.
Thanks,
Kelsey
Can anyone tell me what my error is? It says "Type Mismatch" and stops on the line "ActCode = Application.VLookup(day, Sheet2.Range("H8:H41"), Sheet2.Range("A8:A41"), True)"
This code is supposed to take numerical value "day", find the closest match (not exact) in Sheet2.Range("H8:H41"), and return the corresponding text (string) from Sheet2.Range("A8:A41") saved as ActCode.
Option Explicit
Sub Filldata()
Dim TDHT As Double
TDHT = Sheet2.Cells(43, 8).Value
Dim i As Integer
For i = 1 To TDHT
Dim ActCode As String
Dim day As Double
day = Sheet3.Cells(10, 4 + i).Value
ActCode = Application.WorksheetFunction.VLookup(day, Sheet2.Range("H8:H41,A8:A41"), Sheet2.Range("A8:A41"), True)
Sheet3.Cells(11, 4 + i).Value = ActCode
Next i
End Sub
Any help would be greatly appreciated.
Thanks,
Kelsey