MrExcel Publishing
Your One Stop for Excel Tips & Solutions


Posted by rene van camp on February 16, 2002 5:20 AM


I would like to learn how to create some simple macros and buttons with tasks(like for printing). Can someone tell me where I can find info on how to learn? Thank you in advance, i appreciate your help. rene

Posted by Derek on February 16, 2002 5:41 AM

Hello Rene
A good start is to use the macro recorder.
First customise your toolbar by adding the icon called "button" (comes under Forms and looks like an oblong grey button).
If you click on this icon it will display a small cross. Move this cross to your worksheet and drag it to produce a button. A dialogue box will open.
Select Record, then name your macro.
Everything you do on your worksheet from now on is being recorded, so try a few things, then stop recording. (sometimes you get a little stop icon floating on your worksheet, but if not, go to Tools, Macro, Stop Recording). It is very important to stop recording, it can be easy to forget.
Now, when you click this button it will repeat everything you just recorded.
Select Shift+F11 to go to the Visual Basic Editor to examine your code. This is a good way to start learning how code is put together and to experiment by changing things and testing the result. Shift+F11 will take you back to your worksheet. To format your button right mouse click it (selecting edit takes you to the macro code for this button again)
I have looked for some simple books on macro language but I find most quite difficult to follow, but by playing with the macro recorder and picking up tips at this site you will soon be able to do a lot of useful things
Good luck

Posted by Joost on March 05, 2002 3:43 AM

I know how to record the macro, but now i want to do something more advanced. I want to select an area (a1:d4) and cut all the rows where A has a value of 25. Then paste them in another sheet.
Is this at all possible to give the selection an IF in the macro?

Posted by aly on March 06, 2002 11:32 AM

I need to learn how to make a Macro, take information from one worksheet to another, but i need the cell it pasts the info in, to change everytime

Posted by Bob on April 25, 2002 1:39 PM

Yeah, you can use an IF statement. just edit the macro, then use the syntax:
IF Worksheets("worksheetname") > cells(r,c)=25 Then
copy and paste and whatever else

r = row and c = column of the cell you want to look at.

Posted by Mel Arquiza on April 29, 2002 7:37 PM

Hi Rene,

This is just simple:
Under Command Button1:
Place this procedure:

Private Sub CommandButton1_Click()
Application.Run "PRINT"
End Sub

Make these as a macro say saveas PRINT macro:

ActiveSheet.PageSetup.PrintArea = "$A$4:$K$100"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Preview:=True, Collate:= _True

Hope this help a bit.


Mel Arquiza
Home Page Design