Select Shapes In Macro
Dec 2, 2006
I have two lines (in a sheet) that I am trying to move based on a formula. The wierd thing is I can get the first one to work fine, but when I select the next line it will not work. I have Line 2, and Line 10. Basically the code is:
ActiveSheet.Shapes("Line 2").select
Selection.ShapeRange.Top = 159
ActiveSheet.Shapes("Line 10").select
Selection.ShapeRange.Top = 300
For some reason it just moves Line 2 no matter what I do.
View 6 Replies
ADVERTISEMENT
May 29, 2014
I have a spreadsheet that has many shapes throughout and are connected together in a specific order. It is basically a drawing of steps and transitions in sequential order. I want to be able to select a group of cells that contain all the shapes that I want to select, run the macro and it select all the shapes within the selected cells. With all the shapes selected that I want, I can move and manipulate them as desired. The other option is to select each shape individually holding shift to make the group selection. The code that I am working with is as follows:
Sub SELECT_SHAPES_too()
Dim SH As Shape
Dim Rg As Range
Set Rg = Selection
For Each SH In Rg.Shapes
SH.Select Replace:=False
Next SH
End Sub
This is the idea that I want to do but I am having problems with the "for each shape in selection" portion.
View 2 Replies
View Related
Jul 19, 2014
I use the code below to insert an image and have it save with the file. I would like for the newly placed image/shape to be selected.
[Code] .....
View 3 Replies
View Related
Aug 30, 2013
Im trying to create shapes Rectangles and Squares with different colours within an excel sheet, where the length and height of the shapes is generated by input values.
Also is it possible to create 3D shapes, again where the size of the shap is generated by input cell values.
View 1 Replies
View Related
Jul 10, 2006
I have a shape that will have no macro. How do I prevent this shape
from being selected and prevent the message that no macro can be found,
when it is clicked?
With shapes that do have macros how do I disable them ?
How do I keep them visible but not have the mouse cursor change on mouse
over and not have the macro run on a mouse click.
I tried to use Enabled = false but apparently that property cannot be used
for a shape.
I need to toggle between enabled and disabled.
View 9 Replies
View Related
May 29, 2014
I have a report that has a set template except that the number of columns change.
I have 3 rectangular shapes with text boxes inside each rectangle. The Shapes take up space vertically between row 8 and 15. In some reports the columns will change, the size of columns might change due to longer text. Is there a macro that will select all the shapes and text boxes and center them column wise between the print area?
View 1 Replies
View Related
Aug 25, 2006
Among many attempts to insert and autosize a comment using VBA manually, which errored, i recorded the following bit. When running the macro, it does format the cell - text, not the comment - text and errors in the line highlighted in red.
Range("A14").Select
Range("A14").AddComment
Range("A14").Comment.Visible = False
Range("A14").Comment.Text Text:="Ladida"
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.ReadingOrder = xlContext
.Orientation = xlHorizontal
.AutoSize = True
End With
I just want to add
.AutoSize = True
or something to that effect to the bit below. Any suggestions?
Range("A14").Comment.Text "Ladida"
View 5 Replies
View Related
Sep 14, 2008
I have one master worksheet named "Season" and 30 other worksheets named "1,2,3,4 and so on to 30". I ideally want to copy the shapes (msoShapeOval) from the worksheets- "1-30" to worksheet- "Season". When the shapes (msoShapeOval) are copied from worksheets "1-30"
I want them to keep thier position that they were in when copied to worksheet- "Season".
The shapes (msoShapeOval) are in range "A1:AZ43" in worksheets "1-30" and would be placed in worksheet "Season" range "A1:AZ43"
View 9 Replies
View Related
Nov 16, 2006
I need to get a macro to select all the data in column "A", sort it in ascending order, omit the blanks if any, then select (highlight) all the data so that another macro can be run.
When I record it, it will only record up to the last row I highlight but the data always changes so there could be more or less.
View 9 Replies
View Related
Dec 18, 2007
I am trying to pause a macro on a protected sheet, select 2 adjacent cells (initially protected), utilize an existing drop down box to select a name from the list, copy the name from the list into the range of cells, then re-start the macro.
I had no problem when there was just one name (see John Smith below). I tried to use the InputBox command but needed to actually type in the name.
ActiveSheet.Unprotect
Range("C27:D27").Select
'ActiveCell.FormulaR1C1 = "John Smith"
' Application.CutCopyMode = False
' ActiveSheet.Paste
'Range("c27:d27") = InputBox("Enter value")
View 4 Replies
View Related
Apr 20, 2008
I have a workbook with a 2 macros "PopulateSheetlist" and "SaveEditedversion"
Normally they are each button operated, and prompt the user with vbYesNo style options. I wanted to write a Macro, say "Macroautomatewkbk that would automatically answer the prompts.
Sub Macroautomatewkbk ()
Call PopulateSheetlist
' Always answer YES or OK to any prompts this macro may offer
Call SaveEditedversion
' Answer No for the 1st prompt and YES for the 2nd prompt
End Sub
MsgBox "Both macros "PopulateSheetlist" and "SaveEditedversion"
' Some error handler here, don't know how this should work exactly.
Could any one please explain how to fill in code in the commented sections in the above sample code?
Edit: I tried recording a macro to do the above, but it only showed the zooming and scrolling that occurred, none of the button prompts being answered.
View 9 Replies
View Related
Dec 3, 2008
I have a macro that opens Word pastes data in from Excel,
I want to be able to paste an arrowed line that I have drawn, also if it changes, I want it to reflect that change.
Here's the
Item("Direction1").Range.InsertAfter Worksheets("BSID").Range("Line3").Value
I have my bookmark in Word setup, I'm guessing that instead of a cell ref I need the name of the Line, which is "Line 3" in this case.
I ran a recorded macro and copied and pasted the line and instead of "Range" I got "Shapes" so I assumed that I just needed to change these words but no joy.
View 9 Replies
View Related
Mar 24, 2009
Where do I find a tutorial or examples to show me how to create bars for gantt chart in excel, based on date values?
View 14 Replies
View Related
Nov 17, 2009
i have an excel file for using my manufacture planning. i dont know why but there was created too many TextBoxes(but its shapes)
I'm giving my excel file , you can see what i'm talking about at G column and 193. field
if you can solve this problem, i will be pleasure to you
View 10 Replies
View Related
Sep 18, 2012
I have some shapes on a worksheet that need deleting on change of a combo box. Unfortunately I'm unable to use the below code as not all the shapes need deleting, just the ones that are named in a table on another worksheet.
For Each s In ActiveSheet.Shapes
s.Delete
Next s
Also not all the shapes named in the table will be on the worksheet as this depends on what is selected from the combo box.
View 2 Replies
View Related
Aug 30, 2009
I am a not too good programmer, but I construct chemotherapy regimens for my medical department. They are used to minimise the risk of wrong dosing to patients, etc. Every regimen is an .xlt file, and about a third of them (there are about 100) generate, in addition to pharmaceutical prescription, automatic letters to patients (for those regimens where patients administer oral dosing at home).
These patient-letters have the hospital's logo on them (the logo is a "shape").
However, the problem is that another hospital also wants to use my system. So I will have to replace all these logos with the other hospital's. I would like to do this in an automated way. I have received the other hospital's logo also as a shape.
I have already constructed a data-inserting macro in a separate file. This macro systematically opens each xlt file and replaces the text in key locations according to the file the macro is in (geographical names, etc.).
Is it possible to automatically replace the logo-shapes in a similar way, with these additional facts/wishes in mind:
1. There is always only one type of shape (a logo) in the xlt files.
2. Even though the shapes are exactly the same, it is possible the names are different.
3. The exact location for the shape is different in each xlt file, so I'd like the replacement to get the same top left coordinate as the one it replaces.
I have constructed 2 different files with the same data-inserting macro, each containing one of the logos (so I can change back to my own hospital) and geographic data. When the data-inserting macro is used, I'd like it to identify the shape in the data-inserting file (there's only one shape in this file), copy it, then identify the shape(s) in the present xlt file, and then replace these, in the exact same location.
View 9 Replies
View Related
Jan 5, 2008
I have some drop down control boxes in rows that I want to be able to delete using a macro. If highlight the rown and use Edit, Delete, the data is gone but the controls are still there. How can I delete this using a macro?
View 3 Replies
View Related
Jun 16, 2013
I want to draw circles from 3 points and other geometrical shapes. The points will be given from clicks on the background picture.
View 1 Replies
View Related
Apr 23, 2008
I'm trying to calculate the area of a Freeform shape.
Is this already stored somewhere e.g a shape property?
If not is there a macro available to do this?
View 12 Replies
View Related
Feb 9, 2010
This code finds and matches the Text value of a Shape to the value of a cell on seperate worksheets within the same workbook.
View 9 Replies
View Related
Feb 23, 2007
I need code to do this: When I select a range of cells, say E20:H24 then hit a button the code behind the button would ungroup all the shapes in that area. So if I have grouped shapes elsewhere, they would be uneffected.
View 9 Replies
View Related
Mar 5, 2007
is there a way to select the group of the shape instead of a single shape i've tried .onAction and Application.Caller to do this ..but this is giving me the single shape that i clicked on instead of the whole group.'
View 9 Replies
View Related
Jul 17, 2007
I would like to completely disable the drop down list on the right-click.
I've got
.CommandBars("Cell").Enabled = False
set up and this works on cells but it still leaves it working on shapes.
.CommandBars("Toolbar List").Enabled = False
is similar. Anyone know how to fix this?
View 9 Replies
View Related
Jul 23, 2007
the VBA to change to colour of a shape based upon the value in a cell?
e.g. if cell "a1" = 10 then colour circle red
View 9 Replies
View Related
Oct 17, 2007
I want to write a macro that uses shapes to hide zeros; I have seen this done before but don't really understand how to set it up for myself.
On my sheet, there is a list of funds (Cells A4 to A79), a mixture of which will make up any given portfolio. Cell A1 houses a drop down list of portfolios. When I change cell A1, the numbers are automatically updated, as they are pulled from other worksheets in the spreadsheet. I want to be able to have the funds with zeroes next to them be automatically hidden. I believe there is a way to do this using shapes.
View 9 Replies
View Related
Feb 10, 2008
Is there a way to define a name (Insert-->Name-->Define) for lines and/or shapes drawn using the Drawing toolbar?
I'd like to assign a specific name to a rectangle I've drawn outside of the sheet print limits. By using an If-Then formula, I'd like to bring that shape into a specified cell based on the conditions of the If-Then statement.
View 9 Replies
View Related
May 29, 2008
I have been researching how to create a macro (that will attach to a button), that will delete ALL Shapes and Pictures in a range of cells. So far I have only met with limited results. The Range can be hard coded into the script as it will not change. Does anyone have a script written already they would care to post? I am using Excel 2003.
View 9 Replies
View Related
Aug 17, 2008
I have a collection of shapes (Rectangles) that are being grouped into a single diagram with the For each shape, index on name, group method. I am having difficulty approaching 2 further issues:
1. before I group them I want to assign the Name, Height and Width to an array so that I can write the array to a worksheet once all the shapes have been identified.
2.Also, the Length needs to be assigned (in some cases it is the Height and in others it is the Width where Length is the larger of Height or Width)to the array for each item. Where is the best place to add the definition of length as it is not relevant to drawing the rectangle but to recording the components.
View 9 Replies
View Related
Apr 30, 2009
I have written some code to insert pictures into shapes as part of a facility management problem I have.
Code takes the names from a list of pictures (ConditionList) and places each one into a corresponding shape - therefore populating a report on the facility.
Works to the point of inserting the pictures OK but if I refresh the ConditionList by adding or deleting pictures, my shapes dont refresh.
Sub ConditionPics()
Dim ConditionListCount As Integer
Dim ShapesCount As Integer
Dim ConditionList As Range
On Error Resume Next
Application.EnableEvents = False
View 9 Replies
View Related
Apr 1, 2009
I want to "GROUP" a selection of objects that are put onto a worksheet. But I won't know until the objects are created what the names of each object will be. When I create the objects I will know which objects that I want grouped together.
When I record a macro when I select then "GROUP" said objects I get the following line of code
ActiveSheet.Shapes.Range( Array("FlowCtrl_S2_Decision000011", "FlowCtrl_S2_Decision00001", "FlowCtrl_S2_Decision000012", "FlowCtrl_S2_Decision00001a", "FlowCtrl_S2_Decision00001b")).Select
Selection.ShapeRange.Group.Select
What I need is how to "dynmically" create the Array(....) portion from say a delimited string. Like
"FlowCtrl_S1_Decision00002", "FlowCtrl_S1_Decision000021", "FlowCtrl_S1_Decision000021_1FlowCtrl_S1_Decision00002
In the attached workbook. When you click the button 7 objects will be put onto the worksheet. I want when the routine is complete that the the 7 objects are "GROUP"ed and given a particular name. So that I can point and select at one item and move all 7 at the same time.
View 9 Replies
View Related