I have the following Macro that is activated when clicking a button.
Sub ClickButton() Dim sShape As Shape Dim rowList As Object Set rowList = CreateObject("System.Collections.ArrayList") For Each sShape In ActiveSheet.Shapes For j = 0 To 3 rowList.Add sShape.TopLeftCell.Row + j Next j rowList.Add sShape.BottomRightCell.Row Next sShape End Sub
However, when I open a worksheet and click a Button assigned this Macro I get a runtime 1004 error on the rowList.Add sShape.TopLeftCell.Row + j line. This error disappears when I click the button the second time.
Any suggestions on how to resolve this?