Hello guys,
I have an macro I am fighting last 5 days with no luck.
I am doing FOR loop every row filled and hidding shapes (pictures) based on value in Column C in every row.
So far I am only in stage that I wish to FOR loop of all shapes and hide or show (just to test that everything works fine so far).
The issue is, that the macro works fine the first time I run it, and if I run it again, I got an error... When I close excel and open again, then I can run the macro once only :/.
In these past 5 days I have tried everything I could posibly find out on the internet, the different kind of IF conditions, such for example If Not Intersect(Range(Cells(i, 14), ActionShape.TopLeftCell) Is Nothing Then (and so many other ways to find shape in a cell.
Getting always same error on IF statement.
See images as errors
I have an macro I am fighting last 5 days with no luck.
I am doing FOR loop every row filled and hidding shapes (pictures) based on value in Column C in every row.
So far I am only in stage that I wish to FOR loop of all shapes and hide or show (just to test that everything works fine so far).
The issue is, that the macro works fine the first time I run it, and if I run it again, I got an error... When I close excel and open again, then I can run the macro once only :/.
Code:
Sub ds()
Dim lastrow As Long
lastrow = Worksheets("Task_List").Cells(Rows.Count, 1).End(xlUp).Row
Dim ShapeAction As Shape
Dim i As Integer
For i = 6 To lastrow
For Each ShapeAction In Worksheets("Task_List").Shapes
If ShapeAction.TopLeftCell.Row = i And ShapeAction.TopLeftCell.Column = 14 Then
MsgBox ShapeAction.TopLeftCell.Row & "-" & ShapeAction.TopLeftCell.Column
End If
If ShapeAction.TopLeftCell.Row = i And ShapeAction.TopLeftCell.Column = 15 Then
MsgBox ShapeAction.TopLeftCell.Row & "-" & ShapeAction.TopLeftCell.Column
End If
Next ShapeAction
Next i
End Sub
In these past 5 days I have tried everything I could posibly find out on the internet, the different kind of IF conditions, such for example If Not Intersect(Range(Cells(i, 14), ActionShape.TopLeftCell) Is Nothing Then (and so many other ways to find shape in a cell.
Getting always same error on IF statement.
See images as errors