Type Mismatch Error...

smartguy

Well-known Member
Joined
Jul 14, 2009
Messages
778
Hello all,

I am using the below macro to find the data in to sheet2 and updated the same in sheet1.

i got " Type Mismatch Error"

Please Help...

Code :

Code:
Sub populate()
Dim LR As Long, i As Long, r As Long
With Sheets("Sheet1")
    LR = .Range("A" & Rows.Count).End(xlUp).Row
    For i = 2 To LR
        With .Range("A" & i)
            r = Application.Match(.Value, Sheets("Sheet2").Columns("A"), 0)
            .Offset(, 1).Resize(, 3).Value = Sheets("Sheet2").Range("B" & r).Resize(, 3).Value
        End With
    Next i
End With
End Sub

Sheet1:


Excel Workbook
ABCD
1StudentMark1Mark2Mark3
21
32
43
54
65
76
87
Sheet1


Sheet2:


Excel Workbook
ABCD
1StudentMark1Mark2Mark3
221012020
33232122
44342324
555762526
Sheet2


Please Help...
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Try this:-
Code:
Dim LR As Long, i As Long, r As Long
With Sheets("Sheet1")
    LR = .Range("A" & Rows.Count).End(xlUp).Row
    For i = 2 To LR
        With .Range("A" & i)
           On Error Resume Next
            r = Application.Match(.Value, Sheets("Sheet2").Columns("A"), 0)
            .Offset(, 1).Resize(, 3).Value = Sheets("Sheet2").Range("B" & r).Resize(, 3).Value
           On Error GoTo 0
        End With
    Next i
End With
 
Upvote 0
Hello MickG...

It's Working Great...

Thanks for your Help Once Again....

images
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,348
Members
452,907
Latest member
Roland Deschain

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
Back
Top