Why is this a run time error 1004?

vbaNumpty

Board Regular
Joined
Apr 20, 2021
Messages
171
Office Version
  1. 365
Platform
  1. Windows
The following line gives me 1004 error and I cannot understand why: searchValue.Offset(p, -5).Resize(b, -16).Borders.LineStyle = xlContinuous


Full code:

VBA Code:
Sub imageCompare()

    Dim dashB As Worksheet
    Dim imageB As Worksheet
    
    Dim findValue As Range
    Dim searchValue As Range
    Dim addMe As Range
    Dim formatMe As Range
    Dim ordrList As Range
    Dim myarray As Variant
    
    Dim j As Integer
    Dim i As Integer
    Dim y As Integer
    Dim p As Integer
    Dim n As Integer
    Dim x As Integer
    Dim b As Integer
    Dim u As Integer
    
    Set dashB = Sheet1
    Set imageB = Sheet4
    Set ordrList = Sheet3.Range("outdata")
    
    myarray = ordrList

    i = Evaluate("=COUNTA(Image!X:X)")
    
    x = 0
    
    For j = 1 To i
        'Setting ID# on updated values
        Set findValue = imageB.Range("X:X").Find(What:=myarray(j, 1), _
            LookIn:=xlValues, lookat:=xlWhole)
        'Using to match values to original launched data
        Set searchValue = dashB.Range("X:X").Find(What:=myarray(j, 1), _
            LookIn:=xlValues, lookat:=xlWhole)
            
        'Find Number of Lines
        y = findValue.Offset(0, -3).value
        p = searchValue.Offset(0, -3).value
        
            If y > p Then
                b = y - p
                
                For u = 1 To b 'insert # of new lines in order
                    
                    searchValue.Offset(p, 0).EntireRow.Insert
                       
                Next u
                
                searchValue.Offset(p, -5).Resize(b, -16).Borders.LineStyle = xlContinuous
                
            End If
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
You cannot resize with -ve numbers.
 
Upvote 0
Solution
You can't use a negative value in Resize (it doesn't work like the OFFSET worksheet function)
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,704
Members
449,048
Latest member
81jamesacct

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