Macros for VBA Excel

Source: Internet
Author: User

Sub Macro2 ()

' Macro2 Macro

' Shortcut key: Ctrl+s

Dim I1 as Integer
I1 = 1

For Loop A1-a End
For I = 2 to Range ("a65536"). End (Xlup). Row
s = Worksheets ("Sheet1"). Cells (I, 1)
If Len (s) > Then
I1 = I1 + 1
Sheet2.cells (I1, 1) = Worksheets ("Sheet1"). Cells (I, 1)
Sheet2.cells (I1, 1). HorizontalAlignment = Xlcenter
Sheet2.cells (I1, 1). VerticalAlignment = Xlcenter

Sheet2.cells (I1, 2) = Worksheets ("Sheet1"). Cells (I, 2)
Sheet2.cells (I1, 2). HorizontalAlignment = Xlcenter
Sheet2.cells (I1, 2). VerticalAlignment = Xlcenter

Sheet2.cells (I1, 3) = Worksheets ("Sheet1"). Cells (I, 3)
Else

Sheet2.cells (I1, 4) = Sheet2.cells (I1, 4) + Worksheets ("Sheet1"). Cells (I, 1) + ","
Sheet2.cells (I1, 4). HorizontalAlignment = Xlcenter
Sheet2.cells (I1, 4). VerticalAlignment = Xlcenter

End If

Next

Sheet2. [A1]. Resize (1, 1). Value = "policy Number"
Sheet2. [A1]. HorizontalAlignment = Xlcenter
Sheet2. [A1]. VerticalAlignment = Xlcenter
Sheet2. [B1]. Resize (1, 1). Value = "Number of cases"
Sheet2. [B1]. HorizontalAlignment = Xlcenter
Sheet2. [B1]. VerticalAlignment = Xlcenter
Sheet2. [C1]. Resize (1, 1). Value = "claim Amount"
Sheet2. [C1]. HorizontalAlignment = Xlcenter
Sheet2. [C1]. VerticalAlignment = Xlcenter
Sheet2. [D1]. Resize (1, 1). Value = "Chuxian Place"
Sheet2. [D1]. HorizontalAlignment = Xlcenter
Sheet2. [D1]. VerticalAlignment = Xlcenter


MsgBox ("Execution Complete")
End Sub

Macros for VBA Excel

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.