¤½¥q¥Îªù¸T¨t²Î·í¦Ò¶Ô¡A¸ê®Æ»Ýn¤H¤u¤ñ¹ï ³Â·Ð¡A»ÝnÀ°§U
- ©«¤l
- 2
- ¥DÃD
- 1
- ºëµØ
- 0
- ¿n¤À
- 3
- ÂI¦W
- 0
- §@·~¨t²Î
- LINUX
- ³nÅ骩¥»
- 7
- ¾\ŪÅv
- 10
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2013-5-20
- ³Ì«áµn¿ý
- 2013-5-22
|
¤½¥q¥Îªù¸T¨t²Î·í¦Ò¶Ô¡A¸ê®Æ»Ýn¤H¤u¤ñ¹ï ³Â·Ð¡A»ÝnÀ°§U
½Ð±Ð¦U¦ì¥ý¶i:
¦pªG¤p§Ì¤âÃ䦳¥÷¥´¥d¸ê®Æ»Ýn§@¤ñ¹ï ¦ý¬O¤Hû¥X¤Jªº®É¶¡¦³«D±`¦h«ÂЮɶ¡
¦Ó§Ú¥un¬Ý·í¤Ñ²Ä1¦¸¨êªº ©M³Ì«á¤@¦¸¨êªº ¦p¦ó¤ñ¹ï¬d¬Ý??
¥H¤U¬°¤p§Ìªºexcel¦ì¸mÀÉ ÁÂÁÂ
https://docs.google.com/file/d/0B-xRp_Mu1bOQcG1jSFAzVHByZDg/edit?usp=sharing
1¤Ñ¤º ¥i¯à·|¦³5~8¦¸ªº¶i¥X°O¿ý¡A ©Ò¥H ±Æ§Ç¤§«á ÁÙn¤@Ó¤@Ó¤ñ¹ï «D±`¤H¤u¡A«D±`¶O®É¡C |
|
|
|
|
|
|
- ©«¤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-5-21 20:25 ½s¿è
ÁÙ¦³¥t¤@ºØ...±q¥~³¡¸ê®ÆªºMicrosoft Query¹ï¤u§@ªí¬d¸ß
¤£¹Lnµy·LÀ´SQL»yªk¡A©³¤U¬O¿ý»s«áק諸VBA µ{¦¡
Sub ExcelQuery()
Dim sSQL, driverID As Long
driverID = 1046 'Excel2010:1046 ; Excel2003:790
sSQL = Array("SELECT `Sheet4$`.û¤u½s¸¹, `Sheet4$`.©m¦W, `Sheet4$`.¨ê¥d¥d¸¹, `Sheet4$`.³¡ªù, `Sheet4$`.¾ºÙ, `Sheet4$`.¨ê¥d¤é´Á, " _
, "Min(`Sheet4$`.¨ê¥d®É¶¡) AS ¤W¯Z®É¶¡, Max(`Sheet4$`.¨ê¥d®É¶¡) AS ¤U¯Z®É¶¡" _
, " FROM `" & ThisWorkbook.FullName & "`.`Sheet4$` `Sheet4$`" _
, " GROUP BY `Sheet4$`.û¤u½s¸¹, `Sheet4$`.©m¦W, `Sheet4$`.¨ê¥d¥d¸¹, `Sheet4$`.³¡ªù, `Sheet4$`.¾ºÙ, `Sheet4$`.¨ê¥d¤é´Á" _
)
ActiveWorkbook.Worksheets.Add
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"ODBC;DSN=Excel Files;DBQ=" & ThisWorkbook.FullName, _
";DefaultDir=" & ThisWorkbook.Path, _
";DriverId=" & driverID, _
";MaxBufferSize=2048;PageTimeout=5;") _
, Destination:=Range("$A$1")).QueryTable
.CommandText = Array(sSQL)
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "MS_QUERY_³s½u"
.Refresh BackgroundQuery:=False
'¤£«O«ù³s½u
.Delete
End With
End Sub |
|
|
|
|
|
|
- ©«¤l
- 2839
- ¥DÃD
- 10
- ºëµØ
- 0
- ¿n¤À
- 2895
- ÂI¦W
- 0
- §@·~¨t²Î
- ¡e²¤¡f
- ³nÅ骩¥»
- ¡e²¤¡f
- ¾\ŪÅv
- 100
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¡e²¤¡f
- µù¥U®É¶¡
- 2013-5-13
- ³Ì«áµn¿ý
- 2024-12-22
|
¤]³\¥i¦Ò¼{¼Ï¯Ã¤ÀªRªí¡G
http://www.funp.net/841064 |
|
|
|
|
|
|
- ©«¤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
|
¥»©«³Ì«á¥Ñ GBKEE ©ó 2013-5-21 13:41 ½s¿è
¦^´_ 2# mack078 - Option Explicit
- Sub Ex()
- Dim AR(), i As Integer, R As Long, A, D_Max As String, D_Min As String, xlDay As String
- xlDay = Format(Date, "YYYYMMDD")
- With Sheets("¨ê¥d¸ê®Æ®w") ' *** ½Ðקאּ§Aªº¤u§@ªí¦WºÙ ***
- .Range("A:A").AdvancedFilter xlFilterCopy, , .Cells(1, .Columns.Count), True
- '¶i¶¥¿z¿ï : AÄæ ¤£«½Æ [û¤u½s¸¹] ©ó¦¹¤u§@ªí³Ì¥kÄæ
- R = .Cells(.Rows.Count, .Columns.Count).End(xlUp).Row '¤u§@ªí³Ì¥kÄæ : ³Ì«á¦C¦³¸ê®Æªº¦C¼Æ
- If R = 1 Then Exit Sub 'R = 1 : ¨ê¥d¸ê®Æ®w¤¤¨S¸ê®Æ
- ReDim AR(1 To .Cells(.Rows.Count, .Columns.Count).End(xlUp).Row)
- AR(1) = Array("û¤u½s¸¹", "©m¦W", "¨ê¥d¥d¸¹", "³¡ªù", "¾ºÙ", "¨ê¥d¤é´Á", "¤W¯Z®É¶¡", "¤U¯Z®É¶¡")
- For i = 2 To .Cells(.Rows.Count, .Columns.Count).End(xlUp).Row
- .Range("A1").AutoFilter 7, xlDay '¦Û°Ê¿z¿ï :²Ä7Äæ(¨ê¥d¤é´Á) ·Ç«h =xlDay
- .Range("A1").AutoFilter 1, .Cells(i, .Columns.Count) '¦Û°Ê¿z¿ï :²Ä1Äæ(ID) ·Ç«h =¤u§@ªí³Ì¥kÄ檺I¦C
-
- R = .[A1].End(xlDown).Row
- If R <> .Rows.Count Then '¦³¿z¿ï¨ì¸ê®Æ: ³Ì«á¤@¦Cªº¦C¸¹ <> Rows.Count=Àɮ׳̳̫á¤@¦Cªº¦C¸¹
- D_Min = Application.Min(Sheet1.Range("H:H").SpecialCells(xlCellTypeVisible))
- 'SpecialCells(xlCellTypeVisible):¥i¨£Àx¦s®æ
- D_Max = Application.Max(Sheet1.Range("H:H").SpecialCells(xlCellTypeVisible))
- If D_Min = D_Max Then D_Max = " "
- A = .Range("A" & R).Resize(1, 8) '¿z¥Xªº¸ê®Æ³Ì«á¤@¦C¤§8Äæ½d³ò³]¬°°}¦C¤¸¯À
- A(1, 6) = xlDay '×§ï ¤¸¯ÀªºÈ
- A(1, 7) = D_Min
- A(1, 8) = D_Max
- Else ' xlDay ªº¨ê¥d®É¶¡ ¨S¿z¿ï¨ì¸ê®Æ: = Rows.Count=Àɮ׳̳̫á¤@¦Cªº¦C¸¹
- .Range("A1").AutoFilter 7 '¤£³]©w²Ä7Äæ(¨ê¥d¤é´Á)ªº·Ç«h
- R = .[A1].End(xlDown).Row
- A = .Range("A" & R).Resize(1, 8) '¿z¥Xªº¸ê®Æ³Ì«á¤@¦C¤§8Äæ½d³ò³]¬°°}¦C¤¸¯À
- A(1, 6) = xlDay '×§ï ¤¸¯ÀªºÈ
- A(1, 7) = ""
- A(1, 8) = ""
-
- End If
- AR(i) = A '×§ï ¤¸¯ÀªºÈ
- Next
- .AutoFilterMode = False '¨ú®ø ¦Û°Ê¿z¿ï :¨ê¥d¸ê®Æ®w,¸ê®Æ¥þ³¡Åã¥Ü.
- End With
- With Sheets("¬d¸ß").[A1] ' *** ½Ðקאּ§Aªº¤u§@ªí¦WºÙ ***
- '·í¤é¨ê¥d®É¶¡¸ê®Æ,¸m©ó¥t¤@¤u§@ªí.[A1]
- .CurrentRegion = "" '²M°£Â¦³¨ê¥d®É¶¡
- .Resize(i - 1, UBound(AR) - 1).Value = Application.Transpose(Application.Transpose(AR)) 'Âà¸mAR°}¦C©ó½d³ò¤¤
- End With
- End Sub
½Æ»s¥N½X |
|
|
|
|
|
|
- ©«¤l
- 2
- ¥DÃD
- 1
- ºëµØ
- 0
- ¿n¤À
- 3
- ÂI¦W
- 0
- §@·~¨t²Î
- LINUX
- ³nÅ骩¥»
- 7
- ¾\ŪÅv
- 10
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2013-5-20
- ³Ì«áµn¿ý
- 2013-5-22
|
|
|
|
|
|
|