Making a macro flexible

A

Anderson

I tried to create a macro that would allow me to select individual shapes and
add a new user-defined cell to the shape. The problem is that the macro
doesn't allow me to select a new shape each time i execute the macro. It
keeps trying to add the same user-defined cell to the original shape i
selected.
How do i make the macro smart enough to allow me to pick different shapes?
 
J

John Goldsmith

Hello Anderson,

Have a go with this:

Sub MyUserCell()

Dim shp As Shape
Dim iRow As Integer

If Not ActiveWindow.Selection Is Nothing Then
Set shp = ActiveWindow.Selection.PrimaryItem
If Not shp.SectionExists(visSectionUser, 0) = True Then
shp.AddSection visSectionUser
End If
iRow = shp.AddRow(visSectionUser, visRowLast, visTagDefault)
shp.CellsSRC(visSectionUser, iRow, visUserValue).RowNameU = "MyCell"
shp.Cells("User.MyCell").FormulaU = 1
End If

End Sub

Best regards

John


John Goldsmith
www.visualSignals.co.uk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top