One of the summary of VBA development experience: using the Range object to design the user interface, vbarange
After reading "EXCEL Professional Development", the biggest shock is the author's pursuit of VBA technology and the design of Excel art. Inspired by the author of this book, I also intend to sum up some of my daily development experience to serve as my knowledge reserve and share it on the Internet.
The formatting of Excel formulas, functions, and cells provides great convenience for UI design. This content is detailed in "Excel Professional Development", so you don't have to go into details. In this book, we also discuss pre-defined names. Predefined names are an important part of worksheet user interface design, including predefined naming constants, naming regions, and naming formulas. This article will summarize the role of the naming area in the uidesign.
1. You can name different regions according to specific data requirements to ensure the independence of each part of information and facilitate data verification or regional verification, for example, you can name the customer information and sales information in the sales analysis respectively to analyze the data or information of the two parts.
After using this method, you can determine whether or not the relevant naming area is selected. Some functions related to the area can be used:
Application.Intersect Application.Union
2. You can set up indexes for each column in the named area using the enumeration type, so that the UI can be modified in a unified manner.
3. flexible use of relative references to absolute references.
4. Use the worksheet Protect method to Protect the UI, so as to prevent accidental input of bad data and damage the consistency.
5. Set the title row and data row to a Public constant variable for use.
6. Change the number of rows used to the worksheet attribute for easy calling.
PS Special TIPS of several VBA:
1. IF of VBA does not support conditional short circuit;
2. open the file in EXCEL of different processes.
With Application .DisplayAlerts = False .IgnoreRemoteRequests = True .DisplayAlerts = True End With
How to add an excel vba range object?
Directly write the result of adding to another cell
Range ("c1") = Range ("a1") + Range ("b1 ")
Save the addition result to a variable.
I = Range ("a1") + Range ("b1 ")
Use of range objects in word vba
You have the right idea:
S1 = ActiveDocument. Range. Start
S2 = ActiveDocument. Range. End
S1 returns the beginning of the activity document
S2 returns the end Of the activity document
To move the cursor to the end of the document, write as follows:
Selection. MoveRight Unit: = wdWord, Count: = 1