Excel VBA-Sheet object

Source: Internet
Author: User

Source: http://blog.csdn.net/alexbnlee/article/details/6910151

Worksheet reference

Worksheets (3). Select where 3 is Index, which is the order below
Worksheets ("Sheet3"). Select where Sheet3 is Name
Sheet3.Select here, the Sheet3 is CodeName

Array

For Each Rng in Range ("A1: J10 ")
For Each Sht in Worksheets
For Each Book in Workbooks

Add Worksheet

Worksheets. Add. Name = "worksheet" directly Add a worksheet named "worksheet" at the beginning
Set Sht = Worksheets. Add (after: = Worksheets (Worksheets. Count)
ActiveSheet. CodeName indicates that table creation is assigned a sequential Name, namely, Sheet1 and Sheet2... in the project window, CodeName on the left and Name on the right.
ActiveSheet. Previous. Activate Previous worksheet activated
ActiveSheet. Next. Activate the last worksheet activated

Rows and columns

Rows (1). Select the first line
Rows ("1"). Select the first line
Colums (1). Select the first column
Colums ("A"). Select the first column
Cells (1, 1). EntireRow. Select the row of the selected cell
Cells (1, 1). EntireColumn. Select the column where the selected cell is located
Rows (""). Select the first to fourth Rows.
Columns ("A: D"). Select the first to fourth Columns.
Columns ("A: F"). AutoFit automatically distributes these Columns appropriately
Rows (""). AutoFit automatically distributes these Rows

WorkSheet event
Triggered when WorkSheet_Activate activates the document
WorkSheet_Change content change
WorkSheet_SelectionChange
Triggered when you right-click WorkSheet_BeforeRightClick
WorkSheet_BeforeDoubleClick is triggered when you double-click the left button.
WorkSheet_Calculate triggers an event when the unit is calculated and the formula is run.
WorkSheet_Deactivate this event is triggered when the worksheet is switched.
Source: http://msdn.microsoft.com/zh-cn/library/d4f0cb22%28v=VS.80%29.aspx

Copy between worksheets:

Sub sdlkfj () Sheets ("road bed (2 )"). activate Cells. select 'all copies Selection. copy Sheets. add before: = Sheets (2) Cells. select ActiveSheet. paste 'paste all Application. cutCopyMode = false' disable cut copy mode End Sub

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.