.
'Upload Reference call
Process Control
If statement:
Sub testif ()
Select case statement:
Sub testselectcase ()
Loop Control:
Sub testfor1 ()
Finally, let's talk about the with syntax and line feed of VBA statements. the with syntax is used to reduce the input burden of the program. In the with range class, the default current object is the object specified
property is the feature of the VBA object ' The method that represents the property of an object is ' object. Property = property value Sub ttt () Range ("A1"). Value = The End Sub Sub Ttt1 () Sheets (1). Name = "Worksheet renamed" End sub Sub Ttt2 () Sheets ("Sheet2"). Range ("A1"). Value = "ABCD" End sub Sub Ttt3 () Range ("A2"). Interior.ColorIndex = 3
), Xor (XOR), EQV (equal), IMP (implied)(4) Relational operators = (same), The like, is (5) bitwise operator NOT (logical), and (logical AND), or (logical OR), Xor (Logical XOR), EQV (logicaletc), IMP (implied)Section three: Data types VBA has 12 data types, as shown in the following table, and users can customize the data type with type based on the following types. Fourth: Variables and Constants (1) VBA
and), or (logical or), XOR (logical exclusive or), eqv (logical, etc.), IMP (implicit)
Section 3 Data TypesThere are 12 Data Types in VBA. For details, see the table below. You can also use type to customize the data types according to the following types.Data Type Identifier byteString string $ String Length (0-65400)Byte No 1Boolean No 2Integer integer % 2Long 4Single precision type single! 4Double #8Date type: No 8 AD 100/1/1-9999/12/31Currency
VBA Statement Object method Properties' VBA object ' object in VBA is actually what we do with methods, properties in Excel supported by objects ' several common object representations in Excel ' 1, workbooks ' Workbooks represents a workbook collection, all workbooks, Workbooks (n), which represents the nth workbo
"--Enter 100--"Stop" in cell A1.B. " Macro "--check" Enter 100 "--" execute ".Figure 5 Selecting "Record Macro" Figure 6 enter 100 Figure 7 in a cell select "Stop Recording"Figure 8 Click on "Macro" and check "Enter 100"-"execute" Figure 9 execution result5. Write a macro.A. " Development Tools--Visual Basic--View--Project Explorer--Insert--module--Enter the code on the right:--"Save".B. Click on the green right triangle to run. or close the VBA editi
VBA Statement Object method Properties' VBA object ' object in VBA is actually what we do with methods, properties in Excel supported by objects ' several common object representations in Excel ' 1, workbooks ' Workbooks represents a workbook collection, all workbooks, Workbooks (n), which represents the nth workbo
MSDN-Visual Basic: http://msdn.microsoft.com/zh-cn/library/2x7h1hfk.aspx
MSDN-VB statement: http://msdn.microsoft.com/zh-cn/library/865x40k4.aspx
Http://blog.csdn.net/alexbnlee? Viewmode = contents
Use Excel VBA to add a file in Multiple folders to the header and traverse the file)
The hexadecimal index is quite regular)
Python data type-sequence (string, list, tuples)
Python data type-value type)
A
:a1000″)
Totalvalue = Totalvalue + c.value
Next
Averagevalue = Totalvalue/worksheet (1). Range (″a1:a1000″). Rows.Count
The following code program is much faster than the example above:
Averagevalue=application.worksheetfunction.average (Worksheets (1). Range (″a1:a1000″))
Other functions such as count,counta,countif,match,lookup and so on, can replace the same function of VBA program code, improve the running speed of the program.
Method 2: Mi
--------------------
VBA syntax BASICS (II)--------------------
Basic statement
1. Control Program Flow Statement
(1) GOTO statement
This statement transfers the executed program to the statement instruction where the specified
VBA objects' means that a property of an object is represented by the' Object. Property = property ValueSub TTT ()Range ("A1"). Value = 100End SubSub TTT1 ()Sheets (1). Name = "Worksheet renamed"End SubSub Ttt2 ()Sheets ("Sheet2"). Range ("A1"). Value = "ABCD"End SubSub Ttt3 ()Range ("A2"). Interior.ColorIndex = 3End Sub' Second, VBA method' VBA method is an act
type of error to find, they are caused by the logic used in the program.)2. DebugTo ensure that the variables and expressions in your code run as expected, you can use the various debugging tools in VBA to track them. The VBE has the following debugging tools.(1) interrupt mode① Enter the interrupt mode method: Press the F8 key ("Step Over") at the beginning of the procedure. Use the Cut breakpoint (F9 key or click the current blank indicator bar). U
. CloseApplication. screenupdating = trueEnd sub
7. Summary
Using Excel objects for file operations is the simplest and most convenient, and is suitable for beginners. For the Excel file format, this method is preferred if we only read the content in the table. The second method is more convenient for text file operations. To convert text into a table, this method is also suitable.
Ii. Use VBA file processing statements to process files
1. VBA object
Almost 90% of VBA programs operate on objects. VBA has corresponding objects, attributes, methods, and events. objects are the core
A) how to operate objects
Object. attribute, object. method, parent object. Sub-object. Attribute
For example, sheets ("worksheet"). Name ---- sheets ("worksheet") is an object, and name is an object attribute.
Workbook
articles)2. Loop statementsLoop means repeated execution of a code segment. In VBA, there are multiple statement structures that can constitute loops.(1)... Next LoopThe syntax is as follows:For [Command][Exit For][Command]Next [Counter]From the beginning to the end, execute the command block between For and Next repeatedly, unless the Exit For statement is enco
VBA is Visual Basic for ApplicationsVsto is Visual Studio Tools for office
Currently, the company wants to use Excel to implement the report function. I thought vsto was a replacement of VBA. In the vs.net environment, we should use vsto to develop excel.CodeConvert from VBA to Visual Basic. netArticle, More mistakenly thought it was an alternative trend (artic
Using VBA (Visual Basic for application) macros in office Office software
Tang Tiexin
Talk about macros, many people think of macro virus, in fact, if there is genuine anti-virus software, open real-time protection, set a good macro security, you can use macros to complete many office automation functions.
Open the Word software, from the file main Menu "Tools"-> "Macros"-> "Security", set security to, so you can choose to execute macros. When you
specific content will be discussed in the variable scope.
2.3 force variable Declaration
Two methods can force the explicit declaration of Variables
1) write data in the first line of a moduleOption explicitStatement.
2) The VBE window "tool" option "requires variable Declaration
After "require variable Declaration" is set, VBA willThe option explicit statement is automatically generated in the new modu
Excel VBA application development can be ordered from the second bookstore from the basics to practices
Excel and VBAProgramDesign, latest news, expected to go public in September
Latest Progress in Excel and VBA program design (> 75%)
Example: http://maweifeng.cnblogs.com/archive/2006/03/26/359303.html
Excel and VBA programming mini edition:Http://maweif
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.