- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
|
¦^´_ 1# smartpearl
¸Õ¸Õ¬Ý- Option Explicit
- Sub Ex()
- Dim ì©lªº¸ê®Æ As Range, xType(), AR(1 To 2)
- Dim ¸ê®Æªí As Worksheet, I As Integer, ii As Integer, R As Integer
- xType = Array("Actual", "A_REAL", "Plan", "ALLOCATE", "Non_Plan") '5ºØ Type
- Set ì©lªº¸ê®Æ = Sheets("SHEET1").Range("a1").CurrentRegion
- Set ¸ê®Æªí = Sheets("SHEET2")
- ¸ê®Æªí.Cells.Clear
- '*********************************************************************
- 'ì©lªº¸ê®Æ©ó¤u§@ªí, A1¶}©l©ñ¸m
- 'ª`·N : ì©lªº¸ê®Æ,CRP(Føó)ªº²Ä1Ó¦³È: ¸É¤W¨ä¥L¦ì¸mªºÈ,¨Ï¥Î³o¦æµ{¦¡½X
- ì©lªº¸ê®Æ.Columns(6).SpecialCells(xlCellTypeBlanks).Value = "=R[-1]C"
- '*********************************************************************
- I = 1
- Do
- With ì©lªº¸ê®Æ
- R = ¸ê®Æªí.Cells(¸ê®Æªí.Rows.Count, 1).End(xlUp).Row
- If I >= 2 Then
- For ii = 0 To UBound(xType)
- R = R + 1
- With .Rows(I)
- AR(1) = Array(.Cells(2), .Cells(7), .Cells(4), .Cells(5), .Cells(6), .Cells(8))
- 'CUSTOMER TESTER DEVICE DEVICE_GRP CRP TIME
- ¸ê®Æªí.Cells(R, 1).Resize(1, 6) = AR(1)
- If .Cells(9) = xType(ii) Then
- AR(2) = Application.Transpose(Application.Transpose(.Cells(9).Resize(, .Columns.Count - 8)))
- ¸ê®Æªí.Cells(R, 7).Resize(1, UBound(AR(2))) = AR(2)
- With ì©lªº¸ê®Æ.Rows(I + 1)
- '¤ñ¹ï¤W¤UÄ檺¸ê®Æ
- If Join(Array(.Cells(0, 2), .Cells(0, 7), .Cells(0, 4), .Cells(0, 5), .Cells(0, 6)), ",") = Join(Array(.Cells(2), .Cells(7), .Cells(4), .Cells(5), .Cells(6)), ",") Then
- I = I + 1 '¤ñ¹ï¤W¤UÄ檺¸ê®Æ¬Û¦P
- End If
- End With
- Else
- ¸ê®Æªí.Cells(R, 7) = xType(ii)
- End If
- End With
- Next
- Else
- With .Rows(1)
- ' Array(.Cells(2), .Cells(7), .Cells(4), .Cells(5), .Cells(6), .Cells(8), .Cells(9))
- 'CUSTOMER TESTER DEVICE DEVICE_GRP CRP TIME TYPE
- ¸ê®Æªí.Cells(R, 1).Resize(1, 7) = Array(.Cells(2), .Cells(7), .Cells(4), .Cells(5), .Cells(6), .Cells(8), .Cells(9))
- AR(1) = .Range(.Cells(10), .Cells(.Columns.Count))
- With ¸ê®Æªí.[a1].End(xlToRight).Offset(, 1).Resize(1, UBound(AR(1), 2))
- .Value = AR(1)
- .NumberFormatLocal = "m/d;@"
-
- End With
-
- End With
- End If
- I = I + 1
- End With
- Loop Until I > ì©lªº¸ê®Æ.Rows.Count
- With ¸ê®Æªí.Range("A1").CurrentRegion
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .WrapText = False
- For I = 2 To .Rows.Count Step 5
- .Rows(I & ":" & I + 4).BorderAround 1
- Application.DisplayAlerts = False
- For ii = 1 To 5
- .Columns(ii).Range("A" & I & ":A" & I + 4).MergeCells = True
- Next
- Application.DisplayAlerts = True
- Next
- End With
- End Sub
½Æ»s¥N½X |
|