because the Button is in UserForm.'The Button event must be controlled using VBA code.StrModuleSnippet = "private sub frmbtn1_Click ()" Chr (13 )_"Msgbox" "Hello World" " Chr (13 )_"Frmbtn1.Caption =" "This is a Test" " Chr (13) " end sub"ObjVBFormComponent. CodeModule. AddFromString (strModuleSnippet)Catch ex As ExceptionMsgBox (ex. Message Chr (13) ex. StackTrace)End TryEnd SubPrivate Sub objCommandBu
: Network Disk DownloadContent Introduction······For most professionals who do not have a foundation for programming, they tend to have a lot of fear in learning VBA. This book is aimed at such a crowd, with easy-to-understand language and vivid image of the metaphor, and with a large number of illustrations, the seemingly complex concepts and code in Excel, from simple macro recording,
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
VBA Excel programming three-day discussion (1)
VBA Excel programming three-day discussion (2)
VBA Excel programming three-day discussion (3)
Basic table operations
Due to the wide range of table operations, this article mainly us
Although I have said earlier, it is not a good idea to manipulate a workbook in VBA, but sometimes it is unavoidable to do so. In the vast majority of cases, what we want to do is get a workbook object and use it to get the sheet object, and then process the data in the worksheet. The latter part (the action sheet) has been discussed earlier, so this chapter is about how to open, close, and describe two commonly used workbook objects in
eachFinchFS. GetFolder (P). Files - IfF ThenCount = Count +1: IFile (count) =F in Next - for eachMinchFS. GetFolder (P). Subfolders to Zdir M + Next - End Sub"Convert2xlsx.xlsm"1 Subxls2xlsx ()2 DimFilePath, MyFile, IPath, Name, Outpath as String3IPath =Thisworkbook.path4Outpath =Dir(IPath "\xlsx", vbdirectory)5 IfOutpath ="" Then6 MkDir(IPath "\xlsx")7 End If8MyFile =Dir(IPath "\*.xls")9 Ten IfMyFile "" Then One Do A on Error Resume Next - IfMyFile = Thisworkbook.
The error message given by Excel VBA error is minimal and requires the full use of various tools for debugging.1. Compilation errorsCommon compilation errors include the following:The wrong source code format, such as missing then after if: In the editor, the line turns red.Incorrect syntax structures, such as if and end if do not correspond: The code will be given a compilation error before it is run.Type
Order Information:Excel VBA application development can be ordered from the second bookstore from the basics to practicesHttp://www.cnblogs.com/maweifeng/archive/2006/08/22/483790.html
Since last year, some people have repeatedly posted questions or sent emails for the electronic version of "Excel and VBA programming" released on my website. If I haven't reflect
;■ First formDo [Until condition][Command][Exit Do][Command]Loop■ Second formDo[Command][Exit Do][Command]Loop [Until condition]Execute the command until the condition is met and exit the loop.(4) While... Wend LoopIts syntax is:While [Command]WendWhen the conditions are met, the command is executed.(For more information and examples of loop statements, see a series of articles)--------------------ProcessA process consists of a group of
objOutlook = Nothing46.47. End Sub
Paste a button in Excel and click the event to point to this process. Microsoft Outlook 11.0 Object Library must also be referenced in the Visual Basic Editor of Excel. The specific component name may vary depending on the installed Outlook version. You can only use Outlook instead of Outlook Express.
You must Configure Outlook correctly to use the default account to send
To use VBA to close the workbook, use the Workbook.close method, and to exit Excel, use the Application.Quit method.Here are some code examples: Close the active workbook, and if the workbook has changes, prompts to save:
Copy Code code as follows:
Sub Closeworkbook ()
Activeworkbook.close
End Sub
If you want to avoid prompting, add the "Sav
This section describes how to use VBA to select a file and use VBA to open a file.Clicking open file will pop up a Windows File opening dialog box. In Excel, how does VBA implement this function?
Sub selectfile ()Dim filename as Variant'The file name returned by the open file dialog box is a full-path file name. Its v
= 1 thenSelection. offset (1, 0) = 10Elseif selection. value = 2 thenSelection. offset (1, 0) = 20Elseif selection. value = 3 thenSelection. offset (1, 0) = 30Elseif selection. value = 4 thenSelection. offset (1, 0) = 40Elseif selection. value = 5 thenSelection. offset (1, 0) = 50End ifAbout select case
When you have to test many conditions, you can use the select case statement to replace if then... elseif.
Syntax
As follows:
Sub test ()Select case selection. Value
The following class excellibrary is a very common class that uses VBA to manipulate excel. It is my summary, arrangement, and reference in my work (I have used some examples from Microsoft) I have made many improvements and usage, and I will share them with you here.At first, the program had no comments. For ease of understanding, I just added some comments.
'Man
Directory
Chart Export
Chart Format
Chart Lengend
Chart Protect
Chart Title
Chart
Chart Export
1. Save the chart in Excel to a picture in GIF format on your hard disk
Sub ExportChart() Dim myChart As Chart Set myChart=ActiveChart myChart.Export Filename:="C:\Chart.gif", Filtername:="GIF" End Sub
Theoretically charts can be saved to any type of picture file that readers can try for themselves.
2. Export a chart in
There are many ways to merge Excel workbooks. Examples of combining workbooks are described in "merging data from multiple workbooks into one Workbook. The following examples are provided for your reference.
For example, you need to merge worksheets from multiple Excel workbooks into one workbook. Assume that the work
are placed in multiple Microsoft programs. , you must enclose the server name in double quotes or give it a VBA nullstring property, even if the server is running on the local computer.
Topic1, Topic2,... is 1 to 253 parameters, which are put together to represent a unique real-time data.
The RTD COM Automation add-in must be created and registered on the local computer. If you do not have a live data server installed, an error message appears in t
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.