Creating a macro

  • Thread starter Thread starter Gene Goldenfeld
  • Start date Start date
G

Gene Goldenfeld

I want to create a macro in Excel 2000 using one already written by
someone else. but all I find are instructions to create one from scratch
the normal keyboard/mouse way. Is there a more direct way to create and
copy one in? The macro in question is here:
http://www.cpearson.com/excel/unselect.htm. Thanks,

Gene
 
It's just like copying and pasting text:

Open the VBA (Visual Basic for Applications) editor (how you do this may
vary according to the particular version of Excel); in Excel 2003 this is
done by selecting Tools menu, Macro command, select Visual Basic Editor from
the pop-up menu.

Copy the text of the macro you want to use. Paste the text into the VBA
macro sheet (either a new module or on the macro sheet associated with a
particular worksheet) by selecting the Edit menu, Paste command. Then edit
the macro to suit your needs.
 
Fred said:
It's just like copying and pasting text:

Open the VBA (Visual Basic for Applications) editor (how you do this may
vary according to the particular version of Excel); in Excel 2003 this is
done by selecting Tools menu, Macro command, select Visual Basic Editor from
the pop-up menu.

Copy the text of the macro you want to use. Paste the text into the VBA
macro sheet (either a new module or on the macro sheet associated with a
particular worksheet) by selecting the Edit menu, Paste command. Then edit
the macro to suit your needs.

Thanks. What I have been clear about is that in opening VBE there are
three windows with different titles (after the WFXL2000.XLS):
-1) Print2WinFax (tools) with a macro in it
-2) ThisWorkbook (Code) with a little text
-3) Sheet1 (Code) with a little text

Not sure why WinFax is there, but which do I use?

Gene
 
Gene Goldenfeld said:
Thanks. What I have been clear about is that in opening VBE there are
three windows with different titles (after the WFXL2000.XLS):
-1) Print2WinFax (tools) with a macro in it
-2) ThisWorkbook (Code) with a little text
-3) Sheet1 (Code) with a little text

Not sure why WinFax is there, but which do I use?

Gene

I assume that you don't want to use the macro specifically (and only) for
WinFax so I will ignore it. That leaves "This Workbook" and "Sheet1" (or you
can insert a Module from the Insert menu).

You can really put your code in any one of these three locations ("This
Workbook", "Sheet1", or a new module). Each type of sheet has its own
particular best applications (ie: some code is best put in a particular type
of sheet)...but this gets into the next lesson.
 
Gene, put it in a normal module, try this

To put in this macro, from your workbook right-click the workbook's icon and
pick View Code. This icon is to the left of the "File" menu this will open
the VBA editor, in the left hand window click on your workbook name, go to
insert, module, and paste the code in the window that opens on the right
hand side, press Alt and Q to close this window and go back to your workbook
and press alt and F8, this will bring up a box to pick the Macro from, click
on the Macro name to run it.



--

Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003
 
Paul said:
Gene, put it in a normal module, try this

To put in this macro, from your workbook right-click the workbook's icon and
pick View Code. This icon is to the left of the "File" menu this will open
the VBA editor, in the left hand window click on your workbook name, go to
insert, module, and paste the code in the window that opens on the right
hand side, press Alt and Q to close this window and go back to your workbook
and press alt and F8, this will bring up a box to pick the Macro from, click
on the Macro name to run it.

Ok, that worked. And to Fred, I see that it went in the Sheet page.
Next question: How do I make this macro general, so that it works in all
workbooks? I tried it in another and it didn't quite work the same each
time.

Gene
 
Paul said:
Gene, put it in a normal module, try this

To put in this macro, from your workbook right-click the workbook's icon and
pick View Code. This icon is to the left of the "File" menu this will open
the VBA editor, in the left hand window click on your workbook name, go to
insert, module, and paste the code in the window that opens on the right
hand side, press Alt and Q to close this window and go back to your workbook
and press alt and F8, this will bring up a box to pick the Macro from, click
on the Macro name to run it.


This one is not over yet. I can run the macro, but can't copy it to
another workbook (or otherwise make it general and not just workbook
specific). Help says to open both workbooks, then VBE, then
View/Project Explorer, then drag the module to the other workbook. I
don't see what it is I'm supposed to drag; i.e., I don't see the macro
in the Project - VBAProject list. Thanks.

Gene
 
Gene, if you want it available to all your workbooks put it in your
Personal.xls

You may also what to have a look here on getting started with macros

http://www.mvps.org/dmcritchie/excel/getstarted.htm
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003
 
Paul,
I don't have a Personal.xls I know of and, unfortunately, I find DM
Critichie's instructions on this matter frustratingly difficult to
penetrate (I say that as a writer/editor who used to write computer
manuals). Any other resources to suggest? Thanks.

Gene
 
Gene, if you don't see a personal.xls listed your VBA project list the
easiest way to create one is to start a new workbook and record a macro,
pick to store it in personal macro workbook, stop recording and now you have
a personal.xls in your VBA projects list, just paste the code in it and it
will be available to all your workbooks, delete the macro that you recorded

--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003
 
Paul said:
Gene, if you don't see a personal.xls listed your VBA project list the
easiest way to create one is to start a new workbook and record a macro,
pick to store it in personal macro workbook, stop recording and now you have
a personal.xls in your VBA projects list, just paste the code in it and it
will be available to all your workbooks, delete the macro that you recorded

Thanks. That did it.

Gene
 
Back
Top