formatting autoshapes using VBA, loads of them

dumbledown

New Member
Joined
Nov 8, 2010
Messages
28
Hi,
I have a large diagram with over 400 lines in.
I have another sheet with 2 columns, 1 with the shape names and 1 with values that update - to have values of 1 or 0.

e.g.

Shape_codeNumber
oval 1
1
oval 3870
freeform 2560
oval 271

<tbody>
</tbody>

Is there a way of importing these columns into VBA automatically so that the drawing sheet will only show those shapes with a 1 next to their name. If formatted manually I would just like the lines or shapes to have and colour fill and no line colour.
It would be great if someone could point me in the right direction.
Thanks
Hugh
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
try this:

Code:
Sub test()

Dim Src As Variant
Dim i As Long

Src = Sheet1.Range("u4:v6")

For i = 1 To UBound(Src, 1)
    If Src(i, 2) = 0 Then
        Sheet1.Shapes(Src(i, 1)).Visible = msoFalse
    Else
        Sheet1.Shapes(Src(i, 1)).Visible = msoCTrue
    End If
Next i

End Sub

replace Sheet1 with the correct sheet number, or use Sheets("yoursheetname")
replace "U4:V6" with your range of names and codes
 
Upvote 0
Thanks ChrisM,
That is perfect - however I have misstyped one of the drawing names, there are quite a lot. Do you know how I can I tell which one it fails at.
You are a living legend.
:)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,540
Messages
6,125,409
Members
449,223
Latest member
Narrian

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