vba

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » VBA

VBA

resolvedResolved · Urgent Priority · Version 2013

James has attended:
Excel Introduction course
Excel Intermediate course
Excel Advanced course

VBA

Simple VBA -

Create a button that once pressed will create text in another cell.

Could I get a step by step that simply shows
please?

Thanks

Edited on Fri 5 Aug 2016, 16:26

RE: VBA

Hi James

Thanks for your question.
Here are steps to create a button that adds text to a cell in a worksheet.

1. Press Alt+F11 to open the VB Editor.

2. Select Insert, Module and and type the following macro into Module1

Sub Title()
Range("A1") = "An automated title"
End Sub

This puts the text "An automated title" into cell A1 of the current worksheet.

To get a button to run this macro...

3. Back on the worksheet select Insert, Shapes and draw a button of your choice.

4. Right click and pick assign macro. Choose the macro Title.

The button should now work. To add text to the button itself such as Click to add a title - right click the button and choose Edit text. This allow you to type into the button.

You can edit the macro to suit and choose a different cell to enter the title text. Or you can choose

Activecell = "An automated title"

The text would then get typed into the current active cell on the worksheet.

Our VBA Introduction training takes you through similar macros and more details.

Hope that answers your question.

Regards
Doug Dunn
STL

Fri 12 Aug 2016: Automatically marked as resolved.

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Manually wrapping text

To manually wrap text, use the shortcut key Alt+Enter.

To cancel manual text wrapping, simply delete the new line.

View all Excel hints and tips


Server loaded in 0.04 secs.