Hi All
My Macro copy picture from sheet2 & paste it into Sheet1 with conditions. My Macro perform smooth in debug mode but as i run it by pressing F5 key, it prompt error at different address every time. I have tried the do events as well but still facing the issue.
Kindly address the issues and complete coding is given below.
Dim ab, str As String, a, c, counter As Long, sh As Shape
Set sh = Sheet1.Shapes(1)
For Each sh In Sheet1.Shapes
sh.Delete
Next
a = 5
Do Until IsEmpty(Sheet1.Cells(a, 2).Value)
c = 5
str = Sheet1.Cells(a, 4).Value
For counter = 1 To Len(str)
ab = Mid(str, counter, 1)
If ab = "0" Then
Sheet2.Shapes(1).Copy
doevents
Sheet1.Cells(a, c).Select
ActiveSheet.Pictures.Paste
Else
Sheet2.Shapes(1).Copy
doevents
Sheet1.Cells(a, c).Select
ActiveSheet.Pictures.Paste
End If
c = c + 1
Next
a = a + 1
Loop
My Macro copy picture from sheet2 & paste it into Sheet1 with conditions. My Macro perform smooth in debug mode but as i run it by pressing F5 key, it prompt error at different address every time. I have tried the do events as well but still facing the issue.
Kindly address the issues and complete coding is given below.
Dim ab, str As String, a, c, counter As Long, sh As Shape
Set sh = Sheet1.Shapes(1)
For Each sh In Sheet1.Shapes
sh.Delete
Next
a = 5
Do Until IsEmpty(Sheet1.Cells(a, 2).Value)
c = 5
str = Sheet1.Cells(a, 4).Value
For counter = 1 To Len(str)
ab = Mid(str, counter, 1)
If ab = "0" Then
Sheet2.Shapes(1).Copy
doevents
Sheet1.Cells(a, c).Select
ActiveSheet.Pictures.Paste
Else
Sheet2.Shapes(1).Copy
doevents
Sheet1.Cells(a, c).Select
ActiveSheet.Pictures.Paste
End If
c = c + 1
Next
a = a + 1
Loop