|
-
Aug 28th, 2012, 09:39 PM
#1
Thread Starter
New Member
I am trying to create 50-100 instances of this code
The basic/core code is as follows:
{
On Error Resume Next
Set Shape = ActiveSheet.Shapes("Picture 1")
On Error GoTo 0
If Shape Is Nothing Then
Exit Sub
End If
If Range("Q4").Value < 0.025 Then
ActiveSheet.Shapes("Picture 1").Select
Selection.Cut
End If
}
I am trying to create 50-100 instances of this code where each instance changes a bit. For example, the 2nd code instance must be like this:
{
On Error Resume Next
Set Shape = ActiveSheet.Shapes("Picture 2")
On Error GoTo 0
If Shape Is Nothing Then
Exit Sub
End If
If Range("Q5").Value < 0.025 Then
ActiveSheet.Shapes("Picture 2").Select
Selection.Cut
End If
}
... and the 3rd:
{
On Error Resume Next
Set Shape = ActiveSheet.Shapes("Picture 3")
On Error GoTo 0
If Shape Is Nothing Then
Exit Sub
End If
If Range("Q6").Value < 0.025 Then
ActiveSheet.Shapes("Picture 3").Select
Selection.Cut
End If
}
As you see:
Q4 corresponds to Picture 1
Q5 corresponds to Picture 2
Q6 corresponds to Picture 3
...
Q50 corresponds to Picture 47
...
Q103 corresponds to Picture 100
I am at a loss for writing a more elegant code rather than repeating this for 50-100 times! Could you please show me how to do it?
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|