Determining last row in Macro is one of the most important thing that you need to know for any loop to work.
I will share with you some ways to do it
Example 1: lastrow = Cells(Rows.Count, 1).End(xlUp).Row
Example 2: lastrow = Worksheets("anyname").UsedRange.Rows.Count
Personally I prefer to use method in example 1, this is because I can specify the column in the cells section to use to determine the last row. This allows for some flexibility:)
This blog is dedicated to all who wants to learn Excel, epecially the beginners. I will randomly post topics from the basics to the more advanced functions like how to create a Macro to automate your work. Drop me any comments if you have questions using Excel. Happy reading:)
Showing posts with label Macro. Show all posts
Showing posts with label Macro. Show all posts
Monday, 7 May 2012
Sunday, 6 May 2012
Excel VBA Macro - Record Macro
The simplest way to record a Macro without any programming language is by using the Macro Recorder.
It is a great way for beginners to try!
Important! "Please save your work first before running any Macro, as the actions are not Ctrl+V able.
First click on the Record Macro bottom on the Developer Tab -> Assign a name and press ok.
Then you can do the actions that you want Excel to repeat.
You can do actions like adding formulas, adding text, changing color etc anything you want.
Tips: Plan your actions so that you do not do/undo, this will make your Macro less efficient.
After you are done, press the Stop Recording Bottom at the same place you press the Record Macro bottom.
When you need to run the Macro, you just have to click the Macro button located at the top left corner next to the Visual Basic bottom and press run!
There you go!
It is a great way for beginners to try!
Important! "Please save your work first before running any Macro, as the actions are not Ctrl+V able.
First click on the Record Macro bottom on the Developer Tab -> Assign a name and press ok.
Recording Macro in Excel |
Then you can do the actions that you want Excel to repeat.
You can do actions like adding formulas, adding text, changing color etc anything you want.
Tips: Plan your actions so that you do not do/undo, this will make your Macro less efficient.
After you are done, press the Stop Recording Bottom at the same place you press the Record Macro bottom.
When you need to run the Macro, you just have to click the Macro button located at the top left corner next to the Visual Basic bottom and press run!
There you go!
Excel VBA Macro - Getting the developer tab
The very first step to recording a Macro is really to get the developer tab out from excel.
Beginners often do not know this and they will be spending lots of time looking for the developer tab.
As usual, this is an easy step and you probably will not need to do the steps ever again:)
First click File -> Options -> Customized Ribbons
Then you will see this:
Just check the box on developer and press OK
There you go!
Beginners often do not know this and they will be spending lots of time looking for the developer tab.
As usual, this is an easy step and you probably will not need to do the steps ever again:)
First click File -> Options -> Customized Ribbons
Then you will see this:
Just check the box on developer and press OK
Getting the developer tab |
There you go!
Subscribe to:
Posts (Atom)