Excel VBA Objects: Shape Object (Part 1)

  Рет қаралды 14,072

Excel Macro Mania

Excel Macro Mania

Күн бұрын

Пікірлер: 17
@krn14242
@krn14242 Жыл бұрын
Great video on shapes.
@janiko4271
@janiko4271 Жыл бұрын
hi super helpful videos, i am trying to report for football. looking at target areas in the goal, selection one is all goals for each traget area, selection two is only shots that were succesful/scored and where they were targeted. i am trying to create textbox's for to paste over each zone when wanting to look at selection two, and then delete again when selection one is wanted. i am struggling to have the textbox create in line with the merged cell, e.g. a1 to b1 are merged so the text box is created in the middle rather than the left corner being the top left corner of a1
@ExcelMacroMania
@ExcelMacroMania Жыл бұрын
You need to do some math to get the position you want. For example, the code below adds the text box in the center of range A1:B1, from the center of cell A1 to the center of cell B1 horizontally, while it fits the whole vertical height. You can change the txbTop and txbHeight to center vertically too. You can play with the numbers depending where exactly you wanna put it. Dim rng As Range Set rng = Range("A1:B1") rngWidth = rng.Width rngHeight = rng.Height txbLeft = rng.Left + (rngWidth / 4) txbTop = rng.Top txbWidth = rngWidth / 2 txbHeight = rngHeight Sheet1.Shapes.AddTextbox msoTextOrientationHorizontal, _ txbLeft, txbTop, txbWidth, txbHeight
@jeethendraprabhu8707
@jeethendraprabhu8707 6 ай бұрын
Hi I have data in which I have column A with small shapes (Red, Green & Yellow). And I have to update Column B with color names (Green, Red & yellow). how can I do it? I can select all the shapes through VBA, but I cannot loop through the shapes. please help.. thanks in advance.
@ExcelMacroMania
@ExcelMacroMania 6 ай бұрын
First you need to know the name of the shape in that particular row. Then you can get the color of the shape with the following: ActiveSheet.Shapes("shpName").Fill.BackColor.RGB That returns a number that represents the RGB color, so you need to compare it with the numbers for blue, red, amber.
@indianmonster1445
@indianmonster1445 Жыл бұрын
Dear sir, add shape is good vba code , can you advance ( how to link shape with combobox
@ExcelMacroMania
@ExcelMacroMania Жыл бұрын
You can add a combobox with Shapes.AddFormControl and choosing the type xlDropDown: Sheet1.Shapes.AddFormControl xlDropDown, 50, 50, 50, 50 If you want to link or group that with other shape (for example, a rectangle), you have to target the range array as follows: Sheet1.Shapes.Range(Array("Rectangle 1", "Drop Down 2")).Group
@Godfathergameing01
@Godfathergameing01 Жыл бұрын
Not show shapes option in vba form in toolbox
@ExcelMacroMania
@ExcelMacroMania Жыл бұрын
Not sure what you mean. It sounds like you are trying to add shapes in a userform? There is no shape option indeed, you can just add a picture.
@canaldoferrarezzi4687
@canaldoferrarezzi4687 Жыл бұрын
Hi, how create custom events to shapes?
@ExcelMacroMania
@ExcelMacroMania Жыл бұрын
Do you refer to an event such as clicking the shape? In that case you just add: shp.OnAction = "MyOtherMacro" where shp is a Shape object variable where a given shape or newly added shape has been assigned to (as explained in the video), and MyOtherMacro is the target macro you want to run when clicking the shape.
@canaldoferrarezzi4687
@canaldoferrarezzi4687 Жыл бұрын
@@ExcelMacroMania fine, i try this
@josephdaquila2479
@josephdaquila2479 11 ай бұрын
Does anyone know how to work with shapes that are already on the page? Buttons to be more specific. It seems like I cant get VBA to edit the properties of the button. I'm wondering if I need to go into design mode first somehow?
@ExcelMacroMania
@ExcelMacroMania 11 ай бұрын
That's precisely covered at the beginning of this video. ActiveSheet.Shapes("Button 1").Select (or any other property/method) But that's a normal form control button (design mode does not apply here). If you have an ActiveX control command button you can refer to it as above or using directly the name: ActiveSheet.CommandButton1....However, for an ActiveX control running the macro will exit design mode and some of the properties or methods may not apply. So, probably, you need to use a normal control for what you want to do if it does not let you do it with ActiveX. ActiveX controls are usually preferred when you need to apply events as they come app the sheet module window for the sheet they belong and accept a number of even procedures there.
@josephdaquila2479
@josephdaquila2479 11 ай бұрын
Thank you for your reply. Sorry I missed that explanation/ didn't fully absorb it. I seemed to be able to use the .Select method on an ActiveX button with success. From there I can get edit the properties of the selection just fine. I am mainly working on creating a way to swap between different states of a singular button. My idea is to send the one button to the back, make it white (to blend in with the sheet), and disable the button that gets sent to the back. And run that reverse process for the button I really want at that moment (i.e. bring it to the front, color it, and enable it) Thanks again@@ExcelMacroMania
@ExcelMacroMania
@ExcelMacroMania 11 ай бұрын
@@josephdaquila2479 You should probably use the "Visible" property instead: ActiveSheet.Shapes("Button 1").Visible = False ... then True to show. Same for ActiveX, here you can use Shapes or not. ActiveSheet.CommandButton1.Visible = False Good luck!
@josephdaquila2479
@josephdaquila2479 11 ай бұрын
@@ExcelMacroMania didn't know that was possible. Thank you
Excel VBA Objects: Shape Object (Part 2)
12:04
Excel Macro Mania
Рет қаралды 3,6 М.
Excel VBA Introduction Part 52.1 - Introduction to Shapes
43:00
WiseOwlTutorials
Рет қаралды 48 М.
Men Vs Women Survive The Wilderness For $500,000
31:48
MrBeast
Рет қаралды 99 МЛН
An Unknown Ending💪
00:49
ISSEI / いっせい
Рет қаралды 49 МЛН
15 Tips and Tricks for Working With Shapes In Microsoft Excel
14:27
Learn How to Use Properties and Methods in Excel VBA Effectively
13:09
Excel VBA - Excel To AutoCAD Tutorial
26:44
Everyday Coding
Рет қаралды 12 М.
Excel VBA Objects: Events and Event Procedures
7:58
Excel Macro Mania
Рет қаралды 5 М.
Watch these 28 minutes if you want to become an Advanced VBA user...
29:01
Excel Macro Mastery
Рет қаралды 53 М.
Excel VBA Objects: Properties and Methods
12:44
Excel Macro Mania
Рет қаралды 6 М.
10X Your Excel with Macros & Basic VBA
11:18
Kenji Explains
Рет қаралды 84 М.
Linking Shapes to Data in Excel
8:39
Technology for Teachers and Students
Рет қаралды 102 М.
How To Hide Shapes and Images in Excel with VBA | Excel VBA
5:35
Antriksh Sharma
Рет қаралды 10 М.
Men Vs Women Survive The Wilderness For $500,000
31:48
MrBeast
Рет қаралды 99 МЛН