MACROS!!

  • Thread starter Laura \( '_' \)
  • Start date
L

Laura \( '_' \)

Hiya Could someone explain what a macro is?? and how i would do one?? (any
example will do!)

Thanks

P.s.I can't access certain sites on the internet so please do not provide a
link.

:eek:)

--
@---}--
Laura..... :)
Liverpool, England

"Do you know where you're going to?"
 
B

Bob Phillips

Are you learning Excel in (very) small steps from the NGs? <G>

Normally I would direct you to David McRitchie's page, but I know what you
would say.

A macro is a VBA procedure that can perform an action, or a series of
actions. For instance, it can be a simple Hello World example

Sub Hello()
Msgbox "Hello World"
End Sub

or it can be slightly more complex, such as testing whether a cell have a
value and tell the caller

Sub TestValue()
If Range("A1").Value > 10 Then
Msgbox "Greater than 10"
End If
End Sub

And of course the complexity can get unlimited. Macros can call other
macros, they can pass variable values back and forth amongst each other.

One of the great strengths is that it can make changes to many cells,
something a worksheet function cannot do, or it can set formats, again of
many cells. Like formulae, IF(cond, do A,do B), it can react differently in
different circumstances.

And then you have Functions, similar, but they return a value, and whilst
they can be called from another macro, they can also be called from a
worksheet. So a simple function like

Function Laura(inVal)
If InVal > 100 Then
Laura = "Good score"
ElseIf InVal > 50 Then
Laura = "Average score"
Else
Laura = "Rubbish!"
End If
End Function

Then in a worksheet cell, type

=Laura(56)

and see what happens. Play with different values.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
L

Laura \( '_' \)

Hmm, right I see, Im gonna have to take this in VERY small steps to help me
understand all this.

Thanks very much for taking the time to reply such a detailed answer Bob!!

Big smiley for you! :0)))))))))))

--
@---}--
Laura..... :)
Liverpool, England

"Do you know where you're going to?"
: Are you learning Excel in (very) small steps from the NGs? <G>
:
: Normally I would direct you to David McRitchie's page, but I know what you
: would say.
:
: A macro is a VBA procedure that can perform an action, or a series of
: actions. For instance, it can be a simple Hello World example
:
: Sub Hello()
: Msgbox "Hello World"
: End Sub
:
: or it can be slightly more complex, such as testing whether a cell have a
: value and tell the caller
:
: Sub TestValue()
: If Range("A1").Value > 10 Then
: Msgbox "Greater than 10"
: End If
: End Sub
:
: And of course the complexity can get unlimited. Macros can call other
: macros, they can pass variable values back and forth amongst each other.
:
: One of the great strengths is that it can make changes to many cells,
: something a worksheet function cannot do, or it can set formats, again of
: many cells. Like formulae, IF(cond, do A,do B), it can react differently
in
: different circumstances.
:
: And then you have Functions, similar, but they return a value, and whilst
: they can be called from another macro, they can also be called from a
: worksheet. So a simple function like
:
: Function Laura(inVal)
: If InVal > 100 Then
: Laura = "Good score"
: ElseIf InVal > 50 Then
: Laura = "Average score"
: Else
: Laura = "Rubbish!"
: End If
: End Function
:
: Then in a worksheet cell, type
:
: =Laura(56)
:
: and see what happens. Play with different values.
:
: --
:
: HTH
:
: RP
: (remove nothere from the email address if mailing direct)
:
:
: : > Hiya Could someone explain what a macro is?? and how i would do one??
(any
: > example will do!)
: >
: > Thanks
: >
: > P.s.I can't access certain sites on the internet so please do not
provide
: a
: > link.
: >
: > :eek:)
: >
: > --
: > @---}--
: > Laura..... :)
: > Liverpool, England
: >
: > "Do you know where you're going to?"
: >
: >
:
:
 
J

Jason

For me, a good way to learn about macros in Excel has been to use the
macro recorder. Here's how:

1. On the Excel toolbar, click Tools, Macro, Record New Macro. A
dialog box will open.
2. Assign a name and click ok. A small toolbar should open up.
Ignore that for the moment.
3. In the spreadsheet, make a few changes. Select a new cell, type in
your name, change the color of the background, select another cell,
etc.
4. Now, on the little toolbar that opened, click the button with a
picture of a square.
5. Delete the values you just typed and change the format changes you
made.
6. Press Alt + F8. The macro dialog box will open.
7. Select the name that you just saved and click Run.
8. The macro will repeat the actions that you recorded.

Note: In step 2, if you select "This Workbook" the drop down box
labeled "Store this macro in:", you won't be able to use the macro in
other workbooks.

Another note: If you'd like to look at the vba behind the macro, press
Alt + F11 to open the VBE.

Hope this helps.
 
L

Laura \( '_' \)

Thankyou Jason, that actually helped me a lot!!
Im learning slowly :eek:)

--
@---}--
Laura..... :)
Liverpool, England

"Do you know where you're going to?"
: For me, a good way to learn about macros in Excel has been to use the
: macro recorder. Here's how:
:
: 1. On the Excel toolbar, click Tools, Macro, Record New Macro. A
: dialog box will open.
: 2. Assign a name and click ok. A small toolbar should open up.
: Ignore that for the moment.
: 3. In the spreadsheet, make a few changes. Select a new cell, type in
: your name, change the color of the background, select another cell,
: etc.
: 4. Now, on the little toolbar that opened, click the button with a
: picture of a square.
: 5. Delete the values you just typed and change the format changes you
: made.
: 6. Press Alt + F8. The macro dialog box will open.
: 7. Select the name that you just saved and click Run.
: 8. The macro will repeat the actions that you recorded.
:
: Note: In step 2, if you select "This Workbook" the drop down box
: labeled "Store this macro in:", you won't be able to use the macro in
: other workbooks.
:
: Another note: If you'd like to look at the vba behind the macro, press
: Alt + F11 to open the VBE.
:
: Hope this helps.
:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

MVP's 4
!HELP!! 1
Numbering 8
I THINK ITS TIME!! DO YOU? 5
Put an Outlook contact in an Excel cell? 3
Sticking cells 2
Data, Validation 7
Drop down. *EASY* question! 4

Top