- ©«¤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
|
¦^´_ 31# happycoccolin
¤W¶Çªº¨Ò¤l¡AºÉ¶q«O¯d쥻¸ê®Æªº¯S©Ê(¦p:¬O§_§t¼ÐÀY¡B¬O§_¦³ªÅ¥Õ¡B¬O§_·|¦³«½Æ¶µµ¥µ¥)¡A¤~·|¤ñ¸û²Å¦X¹ê»Ú·Qnªºµ²ªG¡C- Sub TEST()
- Const DATABASE_NAME = "A" '¸ê®Æ®w¤u§@ªí¦WºÙ
- Const DATABASE_COL = 5 'EÄæ
- Const COMPARE_COL = 11 'KÄæ
-
- Dim d, ar, filein, fileout, s As String, i As Long
-
- Set d = CreateObject("scripting.dictionary")
- With Sheets(DATABASE_NAME)
- ar = .[A1].CurrentRegion.Resize(.Cells(.Rows.Count, "A").End(xlUp).Row).Value
- End With
- For i = 2 To UBound(ar)
- s = Replace(ar(i, DATABASE_COL), "-", "")
- If s <> "" Then
- If d.exists(s) Then
- d(s) = d(s) & "," & ar(i, 1)
- Else
- d(s) = ar(i, 1)
- End If
- End If
- Next
-
- filein = Application.GetOpenFilename(FileFilter:="Excel ¬¡¶Ã¯ (*.xlsx),*.xlsx", Title:="¿ï¾Ün¤ñ¹ïªºÀÉ®×")
- If Not TypeName(filein) = "String" Then Exit Sub '¨ú®ø«hµ²§ô
-
- Application.ScreenUpdating = False
- With Workbooks.Open(filein).Sheets(1)
- ar = .[A1].CurrentRegion.Resize(.Cells(.Rows.Count, "A").End(xlUp).Row).Value
- .Parent.Close False
- End With
- Application.ScreenUpdating = True
-
- ReDim Preserve ar(LBound(ar) To UBound(ar), LBound(ar, 2) To UBound(ar, 2) + 1)
- For i = LBound(ar) + 1 To UBound(ar)
- If ar(i, COMPARE_COL) <> "" Then
- s = Replace(ar(i, COMPARE_COL), "-", "")
- If d.exists(s) Then
- ar(i, UBound(ar, 2)) = d(s)
- Else
- ar(i, UBound(ar, 2)) = "No Data"
- End If
- End If
- Next
-
- With Workbooks.Add
- Application.ScreenUpdating = False
- With .Sheets(1).[A1].Resize(UBound(ar), UBound(ar, 2))
- .Value = ar
- .Font.Name = "Verdana" '¦rÅé¦WºÙ
- .Font.Size = 14 '¦rÅé¤j¤p
- .Borders.LineStyle = xlContinuous '®Ø½u
- .EntireColumn.AutoFit '½Õ¾ãÄæ¼e
-
- .Rows(1).Interior.Color = 12567966 '¼ÐÀYÃC¦â
- .Rows(1).Font.Bold = True '¼ÐÀY²ÊÅé¦r
- End With
- Application.ScreenUpdating = True
-
- If MsgBox("¬O§_nÀx¦sÀÉ®×?", vbYesNo) = vbYes Then
- fileout = Application.GetSaveAsFilename(FileFilter:="Excel ¬¡¶Ã¯ (*.xlsx),*.xlsx", Title:="¥t¦s¬°·sÀÉ")
- If Not TypeName(fileout) = "String" Then Exit Sub '¨ú®ø«hµ²§ô
- .SaveAs fileout, FileFormat:=xlWorkbookDefault
- End If
- End With
- End Sub
½Æ»s¥N½X |
|