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