Excel believes that we are familiar with and often deal with it, Excel is basically used to process form data, with some tools and functions, skilled use of tools and functions can make Excel more efficient. However, sometimes the face of some cumbersome data we are also very helpless, then VBA can help you solve this problem, VBA processing data both efficient and more freely, the following small series for everyone to explain in detail what is VBA, how to use?
Tools/raw Materials
Office Excel Software (usually with VBA modules)
It's better to have VB Foundation.
Method/Step
1.VBA What the hell is that?
VBA is a Visual basic for applications abbreviation, is a development module embedded in Office software, this module provides the program to develop autonomously, language Foundation and VB (Visual Basic) similar. You can open the tools-macros-Editor in Excel, or press ALT+F11 to open
2.VBA How to use
After entering the VBA interface, we open the VBA code box, which is open in several ways:
(Explanation: The way the form opens without a default object, when a program is written to work with data from a worksheet or workbook, you must indicate that the object, such as a cell on the Sheet2 worksheet, is written sheet2.cells or sheets (2). Cells; Way two and way one opens, need to indicate the object that the program handles; mode three the Open Code box is the default, or you can reassign the object, such as: Double-click the Sheet1 worksheet, and if you do not specify an object in the corresponding code box, the default corresponds to the Sheet1 worksheet. )
3. Example Analysis
The following small series will illustrate the efficiency and flexibility of Excel VBA with an example program.
Example: E disk has a folder called the VBA department, the folder has 200 xls files, now I need to get the file names of these 200 files.
Specific procedures:
Sub filename Fetch ()
Dim I as Integer
Dim Mydir, MYF, str as String
Mydir = "E:VBA Department"
MYF = Dir (Mydir & "*.xls")
Do While Myf <> ""
str = MYF
i = i + 1
Thisworkbook.sheets (1). Cells (i, 1) = Left (str, Len (str)-4)
MYF = Dir ()
Loop
End Sub
The results of the program operation are as follows:
Let's imagine, if we don't use VBA, do we have any other options? Perhaps the only way is to manually copy and paste, which is still only 200 files, if it is 2000 or 20,000! This is just an example, of course, VBA is not only these, it is very powerful!
Attention matters
VBA is not only in Excel, Word and PPT can be used in VBA to operate
VBA is not so difficult, even if there is no VB based on the can be learned Oh!
VBA in the future use of office work will become increasingly prominent!
What is Excel VBA? What is the role of the relevant introduction, Thank you for reading!