Type mis match & is there a quicker way?

paulsolar

Well-known Member
Joined
Aug 21, 2013
Messages
691
Office Version
  1. 365
Hi All

When the code below gets to the end I get a type mismatch error, have i missed something off the end.

Also is there a quicker way of doing this?

Many thanks in advance

Paul

VBA Code:
Sub Copy_Darren_To_his_Sheet()

   Dim LastRow As Long

   'Find last used row in a Column B of MiReg Installations
   With Worksheets("MiReg Installations")
      LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
   End With

   'Find first row where values should be posted in Darren Jones
   With Worksheets("Darren Jones")
      j = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
   End With
   
  
   For i = 1 To LastRow
       With Worksheets("MiReg Installations")
           If .Cells(i, 2).Value = "Darren Jones" Then
               .Rows(i).Copy Destination:=Worksheets("Darren Jones").Range("A" & j)
               j = j + 1
           End If
       End With
   Next i
   
End Sub
 

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:
VBA Code:
Sub Copy_Darren_To_his_Sheet()
    Application.ScreenUpdating = False
    With Sheets("MiReg Installations")
        .Range("A1").AutoFilter 2, "Darren Jones"
        .AutoFilter.Range.Offset(1).Copy Sheets("Darren Jones").Cells(Sheets("Darren Jones").Rows.Count, "A").End(xlUp).Offset(1)
    End With
    Sheets("MiReg Installations").Range("A1").AutoFilter
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Solution
I test ran your code and did not get any errors.
 
Upvote 0
Sub Copy_Darren_To_his_Sheet() Application.ScreenUpdating = False With Sheets("MiReg Installations") .Range("A1").AutoFilter 2, "Darren Jones" .AutoFilter.Range.Offset(1).Copy Sheets("Darren Jones").Cells(Sheets("Darren Jones").Rows.Count, "A").End(xlUp).Offset(1) End With Sheets("MiReg Installations").Range("A1").AutoFilter Application.ScreenUpdating = True End Sub
Hi Mumps, that is fast, never thought to use a filter, fantastic!!! Cheers
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,624
Latest member
gregg777

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