Runtime error 1004: Application or object-defined error.

yxz152830

Active Member
Joined
Oct 6, 2021
Messages
393
Office Version
  1. 365
Platform
  1. Windows
Gurus,
excel highlighted below code for error in the title...
I was not sure what is wrong with it, but after i added Sheets("abc").activate then it's good to run. But still i cannot see the point of activating the sheet. What is the root cause? Thanks!

VBA Code:
' Sheets("Input").Activate
For Each cell In Sheets("Input").Range(Cells(5, "a"), Cells(800, "a"))
If cell.Value = input_locator Then
With Sheets("Rate").ListObjects(Right(input_locator, 8))
a = .DataBodyRange.Rows.Count
    For Each cell1 In .DataBodyRange.Columns(1).Cells
    If Len(cell1) = 0 Then
    a = a - 1
    Set scan_range = Range(cell.Offset(1, 0), cell.Offset(a, 0))
    GoTo next_step
    End If
    Next cell1
End With
End If
Next cell
 

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.
You need to qualify the cells with the sheet name as well as the range like
VBA Code:
For Each cell In Sheets("Input").Range(Sheets("Input").Cells(5, "a"), Sheets("Input").Cells(800, "a"))
or shorter
VBA Code:
For Each cell In Sheets("Input").Range("A5:A800")
 
Upvote 0
Solution

Forum statistics

Threads
1,215,377
Messages
6,124,597
Members
449,174
Latest member
chandan4057

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