- ©«¤l
- 1018
- ¥DÃD
- 15
- ºëµØ
- 0
- ¿n¤À
- 1058
- ÂI¦W
- 0
- §@·~¨t²Î
- win7 32bit
- ³nÅ骩¥»
- Office 2016 64-bit
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ®ç¶é
- µù¥U®É¶¡
- 2012-5-9
- ³Ì«áµn¿ý
- 2022-9-28
|
¦^´_ 49# happycoccolin - Sub TEST()
- Dim ar, r As Long, i As Long
- Dim cIndexOld, cIndexNew, arNewHeader
- Dim f, findTitle
-
- cIndexOld = Array(2, 3, 4, 5, 7, 8) 'AÀɮפ¤n·h°ÊªºÄæ
- cIndexNew = Array(2, 4, 21, 24, 43, 44) '·h¨ìBÀɦì¸m
- arNewHeader = Array("Q", "W", "E", "R", "T", "Y", "U", "I") '¦Û¤v¶ñ¥þ³¡BÀɼÐÃD¦WºÙ
-
- f = Application.GetOpenFilename(FileFilter:="Excel ¬¡¶Ã¯ (*.xlsx),*.xlsx", Title:="¿ï¾Ü¨Ó·½ÀÉ®×")
- If Not TypeName(f) = "String" Then Exit Sub '¨ú®ø«hµ²§ô
-
- Application.ScreenUpdating = False
- With Workbooks.Open(f)
- With .Sheets(1)
- Set findTitle = .Cells.Find("Item", , xlValues, xlWhole, xlByRows, xlNext) '§ä¼ÐÃD Item
- If findTitle Is Nothing Then MsgBox "§ä¤£¨ì¼ÐÃD": Exit Sub
-
- With findTitle.CurrentRegion
- ar = .Parent.Range(findTitle, .Cells(.Rows.Count, .Columns.Count)).Value
- End With
- End With
- .Close False
- End With
- Application.ScreenUpdating = True
-
- r = UBound(ar)
- With Workbooks.Add
- With .Sheets(1)
- For i = LBound(cIndexOld) To UBound(cIndexOld)
- .Cells(1, cIndexNew(i)).Resize(r).Value = Application.WorksheetFunction.Index(ar, 0, cIndexOld(i))
- Next
- .[A1].Resize(, UBound(arNewHeader) + 1).Value = arNewHeader
- End With
-
- If MsgBox("¬O§_nÀx¦sÀÉ®×?", vbYesNo) = vbYes Then
- f = Application.GetSaveAsFilename(FileFilter:="Excel ¬¡¶Ã¯ (*.xlsx),*.xlsx", Title:="¥t¦s¬°·sÀÉ")
- If Not TypeName(f) = "String" Then Exit Sub '¨ú®ø«hµ²§ô
- .SaveAs f, FileFormat:=xlWorkbookDefault
- End If
- End With
- End Sub
½Æ»s¥N½X |
|