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,
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
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.
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,217,750
Messages
6,138,404
Members
450,134
Latest member
TYoung24

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