VBA Object Architecture
Application Object--represents the entire Microsoft Excel application
Common Properties
Common methods
Common events
ActiveCell
OnWindow
Calculate
Sheetactive
ActiveSheet
Path
ConvertFormula
Sheetdeactive
ActiveWindow
PathSeparator
OnKey
SheetFollowHyperlink
ActiveWorkbook
Range
I
[Getting started with VBA] commonly used and interpreted VBA
[A65536]. End (xlup). Row 'a column last row to the first row with a value
[A1]. End (xldown). Row 'a column first row down first row with a value
[Iv1]. End (xltoleft). column' the last column of the first row has a number column to the first column on the left.
[A1]. End (xltoright). Column 'specifies the number of columns in the first column of
That is, add a worksheet to the workbook, and then move out of the workbook to a new workbook, and copy the code of one module of the workbook to the new workbook before moving out. Here is the key code: '====================================================================== 'Each class list is saved as a single XLS fileActivesheet.moveChDirMyPath'Ignore dialog box, overwrite saveApplication.DisplayAlerts =False 'class name increase "examinee number Processing"
= 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
IamlaosongDiscover a phenomenon that When the application.calculation is automatically calculated, the 2003 version does not seem to reduce the speed of VBA, but the 2007 version has a significant impact and is particularly noticeable when the data is large, especially when the volume is high, and the speed reduction is unbearable. To do this, you must change the application.calculation state to Manual mode, and then restore it at the end of the run.
VBA overview
VBA (Visual Basic for application) is an application of the VB language in office products, based on Visual Basic for Windows Development, Visual Basic for Windows is a programming language developed by Microsoft in 1992 to develop Windows applications that is popular with users because of its simplicity and ease of use. The syntax structure of VBA
Technorati labels: VBA, loop, for, while, do
From: julitta korol, "access.2003.programming. By. example. With. VBA. xml. And. asp", by wordware Publishing, Inc. 2005, p91-p101
(1) using the do... While Loop
Do While Condition
Statement1
Statement2
Statementn
Loop
(2) continuously display an input box until the user enters the correct password
Do While pword
Pword = inputbox ("what is the report p
[VBA study] how to assign cell data to arrays and vba cell arrays
Author: iamlaosong
You can assign the data in a worksheet to an array or assign the data in an array to a worksheet. There are two types of data: one is a loop method, one by one, this method is generally used when special processing is required for each data. The other method is to use a value assignment statement at a time. In terms of spee
Rearrange strings
InStr left LTrim mid right RTrim trim like
Working with strings
Split Jion
Splitting and connecting strings
InstanceSub StrComp operation ()MsgBox StrComp ("ABCD", "ABCD", 1) ' parameter 1 in text comparison, case-insensitive, return 0, representing equalityMsgBox StrComp ("ABCD", "ABCD", 0) ' parameter 0, in binary comparison, returns-1, indicating that the former is less than the latterEnd SubSub StrConv operation ()Msg
IamlaosongWhen using VBA to process Excel files, the key fields of the column number programming is often not known, need to pass parameter settings to know, therefore, when we program, we can not use such a statement to take the number of valid rows:Lineno = [B65536]. End (Xlup). RowThe column name "B" in the above statement, if it is a variable, can be implemented in the form of a string connection, namely:pos_ems = "C"Lineno = Range (pos_ems "6553
IamlaosongWhen the Excel file is processed with VBA, the column number of the keyword segment is often not known when programming. Need to know by the number of parameters, so. When we program, we cannot use this statement to take a valid number of rows:Lineno = [B65536]. End (Xlup). Row ' find valid rows from bottom to topThe column name "B" in the above statement is assumed to be a variable. Can be implemented in the form of a string connection, nam
IamlaosongLooking at a simple loop program, after VBA reads the data from the database, you need to enter a summation formula in the last cell:The formula means cells (i, 9) = Cells (I, 6) + cells (i,7) +cells (I, 8), where rc[-3] represents the formula in the same row The first 3 columns of the cell.How do I represent the first 3 rows in the same column? Very simple, with r[-3]c on it. And so on, the same row after three columns is rc[3], the curre
64-bit Visual Basic for Applications OverviewMicrosoft Visual Basic for Applications (VBA) is the Visual basic version that is included with Microsoft Office. In Microsoft Office 2010, VBA includes language features that enable VBA code to run correctly in both 32-bit and 64-bit environments.Note By default, the 32-bit version of Office 2010 is installed. During
Sub example ()
Dim mytable as table
Set mytable = activedocument. Tables (1)
Mytable. Rows. Last. Select
Selection. insertrowsbelow 1
End sub
Activedocument. Tables (1). Rows. Add seems to be the same. I wonder whether the effects of the two are
note that this version must be combined with the Excel Chinese Character strokes database ("hzbhjsbiao.xls"); otherwise, it cannot be run independently. Function Description: gets the number of strokes of any selected number of simplified Chinese
① First kind of code
On Error GoTo Errhandle
Set MyRange = ActiveDocument.Range (Selection.start, ActiveDocument.Content.End)
For each ichar in Myrange.characters
Selection.MoveRight Unit:=wdcharacter, Count:=1
If Selection.Font.ColorIndex = 2
For background information, see:
Excel and VBAProgramDesign latest news
Writing progress
This chapter is mainly prepared for readers who have no programming experience. Since there has never been any similar writing experience, it is not clear whether the content can be easily understood to achieve this purpose, we also hope that you will put forward suggestions and suggestions for improvement on the content and form.
The detailed content of VBA
personally need to measure whether the VSTO solution to be installed is safe and reliable.VbaVBA is a tool for automating intra-Office client software operations. Because this technology is rooted in Visual Basic 6 and provides support for macro recorder in Word and Excel, VBA provides the possibility of automating tasks within Office documents. However, due to its long history,
What is the VBA language?Believe that the user read this article should know what is VBA, here or briefly, Visual Basic for Applications (VBA) is a macro language of Visual Basic, is developed by Microsoft to perform common automation in its desktop applications ( OLE) task's programming language. Application features that are primarily used to extend Windows, es
You can use Word macro commands to increase your productivity when you edit a document using Word. By default, the security setting for Word macros is high, and macros are automatically disabled when you run the Word Macro command. If you set the Word macro security to Mediu
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.