Run-Time Error Message

J7House1984

New Member
Joined
Oct 30, 2020
Messages
21
Office Version
  1. 365
Platform
  1. Windows
After receiving the Run-Time error '1004':

Method 'Resize' of object 'Range' failed


I am receiving the above error message for the following code. When I stepped into the code to debug it started at the snippet:

inquicker debug.png



What am I doing incorrectly to cause the error message?

VBA Code:
Option Explicit

Sub copyData()
   
    Dim wb As Workbook
    Set wb = ThisWorkbook
   
    Dim tgt As Worksheet
    Set tgt = wb.Worksheets("HealthgradesUploadTemplate")
   
    Dim sLast As Long
    Dim tLast As Long
   
    ' Copy from InQuicker
    With Worksheets("InquickerData")
        sLast = .Range("M:AB") _
                .Find("*", , xlValues, , xlByRows, xlPrevious, , , False).Row
        tLast = sLast - 1
        ' Copy "MRN" Data
        tgt.Range("B8").Resize(tLast).Value = .Range("BR2:BR" & sLast).Value
        ' Copy "First Name" Data
        tgt.Range("D8").Resize(tLast).Value = .Range("S2:S" & sLast).Value
        ' Copy "Last Name" Data
        tgt.Range("E8").Resize(tLast).Value = .Range("U2:U" & sLast).Value
        ' Copy "Middle Initial" Data
        tgt.Range("F8").Resize(tLast).Value = .Range("T2:T" & sLast).Value
        ' Copy "Birthdate" Data
        tgt.Range("G8").Resize(tLast).Value = .Range("AA2:AA" & sLast).Value
        ' Copy "Email" Data
        tgt.Range("H8").Resize(tLast).Value = .Range("Y2:Y" & sLast).Value
        ' Copy "City" Data
        tgt.Range("J8").Resize(tLast).Value = .Range("V2:V" & sLast).Value
        ' Copy "State" Data
        tgt.Range("K8").Resize(tLast).Value = .Range("W2:W" & sLast).Value
        ' Copy "Zip" Data
        tgt.Range("L8").Resize(tLast).Value = .Range("X2:X" & sLast).Value
        ' Copy "Gender" Data
        tgt.Range("P8").Resize(tLast).Value = .Range("AB2:AB" & sLast).Value
        ' Copy "Registration Date" Data
        tgt.Range("U8").Resize(tLast).Value = .Range("M2:M" & sLast).Value
    End With
   
    ' Copy from Control Panel.
    With wb.Worksheets("Control Panel")
        ' Copy "Lead Source" Data
        tgt.Range("Q8").Value = .Range("E6").Value
        ' Value "MAC ID" Data
        tgt.Range("S8").Value = .Range("E8").Value
        ' Value "Status" Data
        tgt.Range("T8").Value = .Range("E10").Value
    End With
   
    ' Copy in ActiveSheet.
    With wb.Worksheets("HealthgradesUploadTemplate")
        tLast = .Cells(.Rows.Count, "D").End(xlUp).Row
        .Range("Q8").AutoFill Destination:=.Range("Q8:Q" & tLast)
        .Range("S8").AutoFill Destination:=.Range("S8:S" & tLast)
        .Range("T8").AutoFill Destination:=.Range("T8:T" & tLast)
    End With

End Sub
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
What is the value of tLast when you get the error?
 
Upvote 0

Forum statistics

Threads
1,213,531
Messages
6,114,167
Members
448,554
Latest member
Gleisner2

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