Type mis match error

smartguy

Well-known Member
Joined
Jul 14, 2009
Messages
775
Hi all,

I got and for the below code:

Code:
Sub ProcessData()
Dim LastRow As Long
Dim sh As Worksheet
Dim i As Long

    Set sh = Worksheets("DFT Dp")
    With Worksheets("Load Sheet")
    
        LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
        For i = 2 To LastRow
            sh.Cells(i, "E").Value = .Cells(i, "H").Value _
                                 * Application.VLookup(.Cells(i, "A").Value, Sheets("Pcode-table").Range("A:AE"), 31, False)
        Next i
    End With
    
End Sub

What is the problem...
 

Some videos you may like

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
23,916
The .Cells property takes two numeric arguments, "E" is not numeric. Try
Code:
LastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
'...
sh.Cells(i, 5).Value = .Cells(i, 8).Value _
                                 * Application.VLookup(.Cells(i, 1).Value, Sheets("Pcode-table").Range("A:AE"), 31, False)
Alternatly,
Code:
With Range(.Cells(2, 1),.Cells(.Rows.Count).End(xlup)).Offset(0,4)
    .FormulaR1C1 = "=RC8*VLOOKUP(RC1,Pcode-table!C1:C31 ,31,FALSE)"
    .Value = .Value
End With
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,122,914
Messages
5,598,840
Members
414,261
Latest member
KatieBsc

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top