3. Use the FileSystemObject object to process files
The FileSystemObject object model is provided by Microsoft to access computer file systems with a large number of attributes, methods, and events. It uses the object-oriented "object. Method" syntax to process folders and files, which is very convenient to use (requires Versions later than Office 2000 ). FileSystemObject is not part of VBA. It is provided as a COM component. Therefore, you must first
1. When writing a VBA function, if the function returns a value, it is written as follows:
'The actual number of rows for obtaining real dataPublic Function GetMaxRow () as integerFor I = MinRow To maxrow' loop the smallest row To the largest rowFor j = MinCol To maxcol' loop minimum column To maximum ColumnIf Trim (Cells (I, j). Value) ExitElse' if each value in this row is empty and until the value in the last column is empty, this action is null.D
When using EXCEL to process data, it is a good choice to add a background color to cells to clearly mark cells that meet specific conditions. Manual processing is simple and quick, but it takes a lot of time and effort to handle large volumes of data ). Code processing is a good choice. Excel can process internal data through VBA programming. After opening the Excel page, you can use the Alt + F11 combination key to start the
First, file formatThe Vba,excel file that you want to use must be saved as a macro-enabled workbook, the XLSM format.Second, start the VBA editorAfter opening the workbook, to start the VBA editor, there are two methods, one is to right-click on the worksheet name, select "View Code", the other is the shortcut key alt+f11Iii. Introduction to the Project ExplorerT
Have a friend to help look at the Excel data how to deal with, the initial look a bit complex, difficult to start. Further analysis, search, found that VBA can be a good solution to this problem, summary record.Description of the problem: for example, there are n sheet, each sheet records a company's transaction details, demand: Statistics out of all companies, each kind of product trading situation.Analysis and arrangement of ideasInitially, these cl
Recently, a series of work to do the maintenance of the website, so do a lot of support tools. There are VBA in Excel, there are tools for direct C # to do. There are times when you need to perform Excel VBA macros in C #, and sometimes even after you execute a VBA macro, get the return value and then handle it accordingly. For ease of use, I've written a Help cl
is Ctrl+f8), and you can run to that statement!The advantage of this approach is that you can bypass the block of statements that you do not want to execute (for example, you explicitly know a problematic statement).However, you can execute the tool----options----Editor----Automatic syntax detection, the Code window input code produces a syntax error, will immediately display an error message!Call stack: When an application is in break mode, it displays the process that has been called!1. How t
) Determines the mandatory return of the message box. When these numbers are added to generate the buttons parameter values, only one number can be taken from each set of values.(2) These constants are specified by VBA and can be used in the program code in place of the actual values.4. Return valueConstants for the return value of the MsgBox functionConstant Value DescriptionvbOK 1 OKVbcancel 2 CancelVbabort 3 TerminationVbretry 4 RetryVbignore 5 ign
Compile Error:The code in this project must is updated for use on64-bit systems.Review and update Declare statements and then mark them with the Ptrsafe attribute.1. Question:32-bit VBA program that is running on the 64-bit system, this compilation error occurs.Environment: Office2010 Excel 64-bit, 64-bit Win7 OS?2. CausesIn the original program, the function is declared as follows. This function compiles and runs in the 32-bit system without problems
The account manager visits a lot of customers every month, the company requires a visit record summary table and to make a visit to the customer's sub-table, so that the supervisor spot checks, the structure of a table. At this time, if a customer fills in a customer, it is very annoying and time consuming. We can do a VBA button, each month as long as the summary part is filled out, just click on the button, automatically generate and customer info
use Excel VBA programming to draw a hexagon on a form. This tutorial is to share with friends the use of Excel VBA programming on the form to draw a hexagonal method, the tutorial is very good, suitable for beginners to learn, recommend you to see it.
Step 1
Open the Excel table and enter the VBE window.
Insert the module.
Programming in Module 1, declaring 4 functions, a structu
= Strresult
' The data in cell D1
Range ("D1″"). Value = Left (Range (A1″), StartNum-1)
' The data in cell E1
Range ("E1″"). Value = Right (range (B1″), Len (range ("B1″)"-j)
End Sub
The code is simple, using just a few VBA functions.
Discuss:
In fact, the code can be further simplified because VBA also has an array function (the Split function).
If you want to make it generic, you can convert the
We introduced the service tag using the MEX contract to invoke the WCF service in COM in such a way that it is convenient to obtain metadata dynamically through the MEX endpoint, but sometimes the metadata of the service may contain sensitive information about the application that a malicious user can exploit. This means that some services may not publish metadata information through Mex for security reasons. If oh, some services do not publish metadata information, with typing is more cumbersom
Download the workbook online, found that there is a password!xxoo, since put on the Internet why to add a password ah?! Later on the internet to find a way to use VBA to crack the worksheet password, to share.
First, when you try to open the workbook, you are prompted with a password:
Using the shortcut key ctrl+f11, open the VBA editing interface and tap the submenu "module" under the "Insert
IamlaosongThere is a pick report, want to first from the product information to separate the color information, and then based on the storage, name and color to create a pivot table, because the data is changed (structure is unchanged, the number of records will change), each re-creation is cumbersome, so want to make a tool, use VBA to separate colors and create a PivotTable report for others to The code that separates the colors is very good to writ
A procedure is a collection that executes one or more given tasks.into: subroutines and functions.1. Sub-Program[Private| Public | Friend] [StaticSub name [(arglist)][staements][Exit Sub][statements]End SubFriend indicates that the sub is visible throughout the project, but object instance controllers are not visible2. function, with return value[Private| Public | Friend] [StaticSub name [(arglist)] [ as type][statements][name= expression][Exit Function][statements][name = expression]End Funct
The difference between ByVal and ByRef
To say that the difference between the two is what it is passing, perhaps this sentence is very vague, let us explain.1, byval-by value, that is to say, we pass to the function is a simple numerical past, the following code to help us understand:
The code is as follows
Copy Code
Sub Run ()Dim I as Integeri = 1Add IMsgBox IEnd SubSub Add (ByVal i as Integer)i = i + 3End Sub
The code above, the I value shown in the fina
In VBA programming, there are also debug features that are used, but are somewhat different from C # and C + +. Especially when you watch an object, you must select it, and then press shift +F9 to make quick watch. Please note the following points:
Insert a breakpoint, put the mouse in front of a line of code, left mouse click can insert a breakpoint, cancel a breakpoint just click on the breakpoint on the left mouse button OK
Single-Step ――――f8. Yo
Functional function DLookup (strfieldname, strTableName, strwhere, objconn)
' Refer to the DLookup function in Access VBA
' Because the environment is different, add the objconn parameter, direct adodb.connection direct redeployment to
Dim strSQL
Dim RS
Set rs = server. CreateObject ("Adodb.recordset")
' Next to call a custom function outside the Checksql ()
strFieldName = Checksql (strfieldname)
If strwhere strwhere = "where" Strwhere
End If
Strsql=
We'd better use the Sina Weibo open platform API to collect, of course, the API must have the app key
Take the following procedure:
1. We know that VBA acquisition data often use an object is the Microsoft.XMLHTTP object, this time also use the object, so we first use VBA to create an object, as shown in the code is to create a Microsoft.XMLHTTP object
2. Then, we casually find an interface, such as we
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.