VBA Syntax

jonny1409

New Member
Joined
Jun 17, 2015
Messages
5
Hello, I wonder if you can help me please?

I have a sheet which has some drawn boxes on there that have macros behind them.
When I click onto the boxes I want them to act as though they are buttons.

They do this by default, but once I put my code behind them, they end up selected (with the squares on each corner).

I can see exactly why this is happening, but I don't know the syntax to stop it.

My code is:

Code:
ActiveSheet.Shapes.Range(Array("Rounded Rectangle 21")).Select
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = "Finance (" + CStr(iCount) + ")"

So it is the xxx.select that is causing it.

How can I change this so that it works the same way, but doesn't select the box?

Thank you,
 

Some videos you may like

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

jonny1409

New Member
Joined
Jun 17, 2015
Messages
5
No idea how to be honest - I'll look it up.
However, there are tons of buttons on this sheet (I didn't design it originally, I'm just looking to improve it in areas) so If I could find out how to do this in the short term it would be great.

Cheers.
 

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
Perhaps something like this:-
This will add text to the active shape reflected by the code.
Code:
Sub Rectangle2_Click()
ActiveSheet.Shapes(Application.caller).TextFrame.Characters.Text = "Today is the " & Date
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,122,906
Messages
5,598,783
Members
414,259
Latest member
beetle12

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
Top