Visual basic for a command button

Last Edited By Krjb Donovan
Last Updated: Mar 05, 2014 10:03 PM GMT

QuestionEdit

I'm trying to create a command button that will reset certain cells to their original data and have no idea how to set up the commands in Microsoft Visual Basic for2007. Any help?

AnswerEdit

Dan

Here is a real simple way that might work for you.

If you copy the original data to another part of the worksheet or to another worksheet, then you can recopy it to the area it was originaly in (basically resetting the cells to their original values) after you are finished.

It is pretty easy to write a macro that will do this simply by making the keystrokes that are necessary and recording them in a macro.

First go to toolbar/tools/macro/record new macro Select or create a name Give the macro a control letter that will run the macro Then clic ok Everything after you click ok will be recorded until you select stop recording by going to toolbar/tools/macro/stop recording.


Paint/select the area to be copied (the copy of your original) data--Then copy the area--then paste to the worksheet (where the original data was) thus replacing the work that you have done with the original work.

After recording these keystrokes remember to select stop recording by going to toolbar/tools/macro/stop recording.

You can now assign the macro to a button, that you create on the worksheet, which will run the macro whenever you click on the button--it will be easiest for you to go to the help and read up on creating buttons and assigning macros to them.

Advertisement

©2024 eLuminary LLC. All rights reserved.