Occasional runtime 1004 error

spl

New Member
Joined
May 26, 2020
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
Hi Folks,

I'm running the below code...and it works fine...some of the time. Other times I get a runtime error but I can't figure out how to resolve it; any tips?

The bit where I get an error is;

VBA Code:
For Each shp In ActiveSheet.Shapes
    If Not Intersect(Range(shp.TopLeftCell, shp.BottomRightCell), r) Is Nothing Then _

I'm guessing something to do with the range dropping out?


VBA Code:
Sub delete_step()

Dim shp As Shape

Dim b As Object, RowNumber As Integer
Set b = ActiveSheet.Shapes(Application.Caller)
With b.TopLeftCell
myvalue = .Column
    End With
Set r = Columns(myvalue)
For Each shp In ActiveSheet.Shapes
If Not Intersect(Range(shp.TopLeftCell, shp.BottomRightCell), r) Is Nothing Then _
shp.Select Replace:=False

Next shp

Selection.Delete
Columns(myvalue).Select
Selection.Delete Shift:=xlToLeft
Dim lastCol As Long
    lastCol = Cells(9, Columns.Count).End(xlToLeft).Column
 Range("G14").AutoFill Destination:=Range(Range("G14"), Cells(14, lastCol)), Type:=xlFillDefault
Call LinkCheckBoxes

End Sub

Thanks in advance :)
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,214,614
Messages
6,120,520
Members
448,968
Latest member
Ajax40

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