What is Excel VBA?

Source: Internet
Author: User

Failure Analysis: Excel VBA is in fact Everyone Code Editor program, some people are considered to be macros, but Excel VBA is included in the macro program. Let's take a look at what Excel VBA is. How do I open it?

One, Excel VBA is what?

VBA in Excel VBA is an abbreviation of Visual Basic for application. Generally used to achieve simple or medium office automation applications. Because it is easy to learn and can be well supported by Office series applications, it has been widely used.

Two, Excel VBA how to open?

Install a VBA editor first, with Visual Basic for application in office sharing features. After you start Excel, select the larger point in the upper left corner, Excel Options-Trust Center-Trust Center Settings-"Macro Settings-" "Disable macros and give notice".

Hint: When you open Excel with VBA, the formula bar will be prompted on the side, be sure to enable it, otherwise you cannot edit and use VBA.

Novice must know: Open Excel appear macros how to solve?

You need to enter the VBA editor, press and hold alt+f11 to open it to write your own code, you can also read the existing code here. If it is a macro, you can run it directly Alt+f8 select Execute.

Third, the use of Excel VBA:

To put it simply, it is simulating manual operation and accomplishing some very tedious things. For example: copied from the internet to Word's article, the format is very messy, you can write a macro yourself, to automate the finishing work, instead of artificial 1.1 point to change, so too tired. The main function uses are as follows:

1. Automate repetitive tasks

2. Customize Excel toolbars, menus, and interfaces

3. Simplify the use of templates

4. Customize Excel to make it a development platform

5. Create a report

6. Complex operation and analysis of data

Here are some of the code-use cases for the visual Basic for application:

1. This example sets the password window (1)

If Application.inputbox ("Please enter password:") = 1234 Then [A1] = 1 ' password is correct when executed

Else:msgbox "Bad password, coming out!" ' This line sets the password end to the 2nd

2. This example sets the password window (1)

x = MsgBox ("Do you really want to checkout?", vbYesNo) if x = vbyes Then Close

3, this example is to set the worksheet password

ActiveSheet.Protect password:=641112 ' Protect worksheet and set password

ActiveSheet.Unprotect password:=641112 ' Undo Worksheet Protection and remove password '

4. This example turns off all workbooks other than the workbook that is running this example, and saves their changes.

For each w in workbooks

If W.name thisworkbook.name Then w.close savechanges:=true End If Next w ' every time you open the workbook,

5. This example maximizes the Microsoft Excel window. Application.windowstate = Xlmaximized '

6. This example displays the name of the active worksheet.

MsgBox "The name of the active sheet is" & Activesheet.name '

7. This example saves a copy of the active workbook.

Activeworkbook.savecopyas "C:tempxxxx. XLS "

Summary: What is VBA? More specifically, it is an automated language that enables you to automate commonly used programs and create custom solutions.

For example, there is a worksheet, often need to update the data, open the data source, adjust the format, add the operation formula, and so on relatively fixed repetitive work, you can use the Marco macro.

One day when you're working, dot tool-macro-record, and then do it all at once, VBA will write all your actions into a macro program. This macro program has basic language knowledge can be understood, but there will be a lot of useless statements. At the very least, running macros later can save you the time to repeat work. Secondly, learning conditions, circulation, variables and other higher-order usage. Learn more and ask more, practice can learn.

Classification:
  • Excel Tutorials

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.