- ©«¤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
|
¥»©«³Ì«á¥Ñ stillfish00 ©ó 2013-8-2 14:13 ½s¿è
¦^´_ 33# happycoccolin
¤@¹ï¦h«½Æªº¸ê®Æ¤¤¬O§_¥i¥H¥u¨ú¤£«½Æªº¨Ã¦b¦P¤@Äæ¦ì¤º°µ´«¦æ°Ê§@©O?
ÁÙ¦³Y¬O²£¥ÍªºÀɮר䤤¤@Äæ¦ì¤Ó¼e¤j¥i¥H¥ÎVBA³B²zÅý¥L³Ì¤j¥u¨ìÄæ¼e50(¨Ã¦Û°Ê´«¦C)³o¤@Ãþªº³]©w¶Ü? - 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 Not d.exists(s) Then Set d(s) = CreateObject("scripting.dictionary")
- d(s)(ar(i, 1)) = "" '²Ä¤G¼h¦r¨å¡A¥Î¨Ó¿z¿ï±¼«½ÆªºAÄæÈ
- 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)) = Join(d(s).keys, vbLf)
- 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
-
- 'Äæ¼e¨î¤Î¦Û°Ê´«¦æ
- With .Columns("F")
- If .Width > 250 Then
- .Width = 250
- .WrapText = True
- End If
- End With
- With .Columns("M")
- If .Width > 250 Then
- .Width = 250
- .WrapText = True
- End If
- End With
- 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 |
|