ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] VBA ·j´M¸ê®Æ¦C¹ïÀ³ªº³Ì¤j­È©Î³Ì¤p­È

¦^´_ 1# junkwei

sql»yªk§Y¥i§¹¦¨
stock.mdb=>´«¦¨§Aªº¸ê®Æ®w¦WºÙ
¬Y¬Yªí=>´«¦¨§A¸ê®Æ®w¤¤ªº¸ê®Æªí¦WºÙ

¥H¤W¬Omdb»yªk¡A·s¸ê®Æ®w½Ð¦Û¦æ·j´M´À´«
  1. Sub ex()

  2.     Worksheets("1").Activate
  3.     Set cn = CreateObject("adodb.connection")
  4.     cn.Open ("Driver={Microsoft Access Driver (*.mdb)};dbq=" & ThisWorkbook.Path & "\stock.mdb")
  5.     Set rs = cn.Execute("select ¯Z¯Å,max(¦~¬ö) as ³Ì¤j¦~¬ö,min(¦~¯Å) as ³Ì¤p¦~¬ö from   ¬Y¬Yªí  group by ¯Z¯Å")
  6.     w = 1
  7.     For Each tt In rs.Fields 'Åã¥Üªí³æ¦WºÙ
  8.         Cells(w) = tt.Name
  9.         w = w + 1
  10.     Next
  11.     Cells(2, 1).CopyFromRecordset (rs)'¥s¥X¸ê®Æ
  12.     cn.Close
  13.     Set cn = Nothing
  14.     Set rs = Nothing

  15. End Sub
½Æ»s¥N½X

TOP

¥»©«³Ì«á¥Ñ owen06 ©ó 2014-11-28 10:47 ½s¿è

¦^´_ 1# junkwei


    §ä´M²Å¦X±ø¥óªº³Ì¤j­È¡G
    ¦bF2¿é¤J=MAX(($A$2:$A$16=E2)*$C$2:$C$16)¡A¦¹¬°°}¦C¤½¦¡¡A¿é¤J§¹¦¨«á­n«öCTRL+SHIFT+ENTER¡A
    ¦A§â¤½¦¡©¹¤U©Ô§Y¥i¡C
   
    §ä´M²Å¦X±ø¥óªº³Ì¤p­È¡G
    ¦bG2¿é¤J=MIN(IF($A$2:$A$16=E2,$C$2:$C$16,FALSE))¡A¦¹¬°°}¦C¤½¦¡¡A¿é¤J§¹¦¨«á­n«öCTRL+SHIFT+ENTER¡A
    ¦A§â¤½¦¡©¹¤U©Ô§Y¥i¡C

TOP

        ÀR«ä¦Û¦b : ¤H­n¦Û·R¡A¤~¯à·R´¶¤Ñ¤Uªº¤H¡C
ªð¦^¦Cªí ¤W¤@¥DÃD