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

[µo°Ý] ½Ð°Ý¦³msgbox¥Î"ª«¥ó¬d¸ß"¥¨¶°¯àÀ°¤p§Ì¸Ñ¨M°ÝÃD¶Ü?

[µo°Ý] ½Ð°Ý¦³msgbox¥Î"ª«¥ó¬d¸ß"¥¨¶°¯àÀ°¤p§Ì¸Ñ¨M°ÝÃD¶Ü?

¤p§Ì¥Ø«e¥¿¦b½s¼g¬ã¨s½×¤å¡A¥Ø«e´N®t³Ì«á¤@¨BÆJ½×¤å´N§¹¦¨¤F¡C

±Ð±Â­n§Ú¦b®×¨Ò³¡¤À¸ê®Æ¶×¤Jexcel¡A¨Ã¨Ï¥Î¤º«Øvba¼gªº¥¨¶°¸É¦b³Ì«á¤@³¹¡AÅý¾ã­Ó®×¨Ò¦n¬Ý¨Ç

¤£¹L±Ð±Âª¾¹D³o¤£¬O§Ú­Ì±Mªø»â°ì¡A¦P·N§Ú¸ß°Ý·|vbaªº¤H¨ó§U

­Yª©¤W¦³°ª¤â¯àÀ°§U¡A¤p§Ì¯u¬O¦b·PÁ¤£¹L¡C

ªþ¥ó¤¤¤p§Ì´£°Ý¤F3­Ó«ü¥Oªº°ÝÃD¡A²Ä1ÃD¤p§Ì¦³¼g¤F¤@¤U¦ý¬O¶]¥Xªºµª®×µLªk±q¤j­P¤p±Æ¦C¡A¦ü¥G¤Ö¤F¨Ç«ü¥O¡C


¡°ªþ¥ó¤¤¦³2­ÓÀɮפ@­Ó¬°wordÀÉ¡A¸Ì­±´y­z¸ß°Ý°ÝÃD¡A¥t¤@­ÓÀɮ׬°excel¨Ò¤l¸ê®Æ¡AÁÙ¦³¤p§Ì¹q¤l«H½c
   ¥D­n¸ß°ÝÃö©ó"msgbox"¥¨¶°¡A»P°ÝÃD¥¨¶°³]©wµ¹¤©½d¨Ò«ü¥O°Ñ¦Ò¡A½Ð¹L¥Ø¡C

Ãö©óExcel VBA½Ð±Ð.rar (17.84 KB)

Ãö©óExcel VBA½Ð±Ð

¦^´_ 1# joey77373
§AÁ|¨Òªºµª®×¦ü¥G»PÀɮפº®e¤£²Å
²Ä¤@ÃD­Y¬O¥H20%¬°°ò·ÇÀ³¸Ó¥u¦³C¡BE

²Ä¤GÃD¬O­n§ä¥XL:Qªº³Ì¤j­È¶Ü?¨ºÀ³¸Ó¬OC¤¸¥óªº­PÀù©Ê%¼Æ
  1. Public Rng As Range
  2. Sub ²Ä¤@ÃD()
  3.     Dim myInput, i As Integer, Ar As Variant, MyMax#, MyStr
  4.     Dim Str As String, Dic As Object
  5.     myInput = InputBox("½Ð¿é¤JÁ`¦¾¬VªùÂe­È(%):")
  6.     Set Dic = CreateObject("Scripting.Dictionary")
  7.     For i = 2 To 9
  8.     If Not IsNumeric(Cells(i, 9)) Then MsgBox "I" & i & "½Ð¿é¤J¼Æ¦r": Exit Sub
  9.       If Cells(i, 9) >= (myInput / 1) Then
  10.          Dic(Cells(i, 1).Value) = Array(Cells(i, 9), Cells(i, 1))
  11.          If Rng Is Nothing Then Set Rng = Cells(i, "L").Resize(, 6) Else Set Rng = Union(Rng, Cells(i, "L").Resize(, 6))
  12.       End If
  13.     Next i
  14.     If Dic.Count = 0 Then MsgBox "¨S¦³²Å¦X±ø¥óªº¤¸¥ó": Set Rng = Nothing: Exit Sub
  15.     TestStr = Join(Dic.keys, ",")
  16.     Do Until Dic.Count = 0
  17.      Ar = Application.Transpose(Application.Transpose(Dic.items))
  18.      MyMax = Application.Max(Application.Index(Ar, , 1))
  19.      MyStr = Application.VLookup(MyMax, Ar, 2, 0)
  20.      MsgBox "¤¸¥ó  " & MyStr & "  " & MyMax
  21.      Dic.Remove MyStr
  22.     Loop
  23. End Sub
½Æ»s¥N½X
  1. Sub ²Ä¤GÃD()
  2. Dim MyMax#, MyStr$, MyTital$
  3. If Rng Is Nothing Then MsgBox "¥¼¦³²Å¦X¤§¤¸¥ó¡A½Ð¥ý°õ¦æ²Ä¤@ÃD": Exit Sub
  4. If Application.Count(Rng) <> Rng.Count Then MsgBox Rng.SpecialCells(xlCellTypeConstants, 2).Address & "¬°«D¼Æ­È¸ê®Æ": Exit Sub
  5. MyMax = Application.Max(Rng)
  6. MyStr = Cells(Rng.Find(MyMax, lookat:=xlWhole).Row, "A")
  7. MyTital = Cells(1, Rng.Find(MyMax, lookat:=xlWhole).Column)
  8. MsgBox "¤¸¥ó  " & MyStr & MyTital & "  " & Format(MyMax, "0.00%")
  9. End Sub
½Æ»s¥N½X
²Ä¤TÃD´N¬Ý¤£¥X»P²Ä¤@¡B¤GÃD¦³¦óÃöÁp©Ê¡A½Ð¸Ô²Ó»¡©ú¤§
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

­º¥ý¡A·PÁÂHsieh¬°¤p§Ì©âªÅ¬Û§U¡A©êºpªí¹F±o¤£°÷¸Ô²Ó¡A¦b¤U­±¸É¥R»¡©ú¡I

²Ä¤@ÃDªº³¡¤À¦]¬°excelµy°µ­×¥¿¡AwordÀɧѰO§óÅܵª®×¡A©êºp¡C

²Ä¤GÃDªº³¡¤À»¡©úA¦ÜH¤¸¥ó¦b¦U¦¾¬VÀô¹Òªº¼vÅT%¼Æ¡AÃD¥Ø¤¤©Ò­z¤§¸ß°Ý
­Y¨Ï¥ÎªÌ·Q§ä¤¸¥óA¦ÜH"·Å«Ç®ÄÀ³"¼vÅT³ÌÄY­«ªº¤¸¥ó¡A«hVBAµ¹¥Xªºµª®×¬°"C¤¸¥ó"
­Y¨Ï¥ÎªÌ·Q§ä¤¸¥óA¦ÜH"­«ª÷ÄÝ"¼vÅT³ÌÄY­«ªº¤¸¥ó¡A«hVBAµ¹¥Xªºµª®×¬°"E¤¸¥ó"

²Ä¤TÃD©Ó±µ²Ä¤GÃD¡A°²¦p¨Ï¥ÎªÌ¦b²Ä¤GÃD¸ß°Ý"·Å«Ç®ÄÀ³"¼vÅT³ÌÄY­«ªº¤¸¥ó
µª®×µ¹¥X"C¤¸¥ó"
±q²Ä¤GÃD¥i¥Hª¾¹DC¤¸¥ó¬O¸Ó²£«~¤¸¥ó¤¤¹ï"·Å«Ç®ÄÀ³"±a¨Óªº¼vÅT³Ì¤j
©Ò¥H¨Ï¥ÎªÌ·|¥h´M§ä¥i¥H´À¥N"C¤¸¥ó"ªº¤¸¥ó¡A³o¤]¬O²Ä¤TÃDªº½×­z
¨Ï¥ÎªÌ±q­ì¥ý"C¤¸¥ó"»P¥i¥H¥Î¨Ó´À¥NC¤¸¥óªº"¤¸¥óC-1"¡B"¤¸¥óC-2"
¦]¬°³o¨Ç´À¥N¤¸¥ó¦b"·Å«Ç®ÄÀ³"³£¤ñ­ì¥ýªº§C¡A©Ò¥H¨Ï¥ÎªÌ¦b²Ä¤TÃD·|¤ñ¸û³o¤T­Ó¤¸¥ó
¹ï"¾ã­ÓÀô¹Ò¦¾¬VÁ`Åv­«­È(¤]´N¬OZÄæ¦ìªº­È)"¡A´M§ä¨®ZÄæ¦ì­È³Ì§Cªº¤¸¥ó¬°C-2
¥Nªí¤¸¥óC-2¬O¥i¥H¥Î¨Ó´À¥N­ì¥ýC¤¸¥óªº´À¥N©Ê¤¸¥ó¡C

¤£ª¾¹D³o¼Ë±Ô­z¦³¨S¦³¤ñ¸û²M·¡¡A·PÁªá¶O®É¶¡À°¦£¡C

TOP

¦^´_ 2# Hsieh
­è­è§Ñ¤F¥Î¦^´_¥\¯à

´£¨Ñªº½d¨Ò°ÝÃD»PExcel«Ü¦n¬Ý¥Xµª®×¡A¦]¬°¯u¹ê¼Æ¾Ú¤W¦Êµ§Ãö«Y¨ì®×¨Ò¤½¥q¾÷±K
©Ò¥H¥u¯à¥Î³¡¤À¼Æ¾Ú¦b¦¹¸ß°Ý·PÁ¯ണ¨Ñ«ü¥OÅý¤p§Ì¯à¶¶§Q°õ¦æ¡C

TOP

¦^´_ 2# Hsieh

§Ú¸É¥R¤@¤U¡A¦]¬°«e­±ªº´y­z§Úµ¹¦³µ{¦¡©³¤lªºªB¤Í¥L­Ì»¡¬Ý¤£À´
­n§Ú­×§ï¤è¦¡¥h´y­z
³o¼ËÁ¿À³¸Ó¤ñ¸û²M·¡

²Ä¤GÃD·Q§e²{ªºµ²ªG
©µ¦ù²Ä¤@ÃDªºµ²ªG¡A¤ñ¸ûL¨ìQ¦UÄæ¦ìªº¤j¤p¡A¨Ò¦p¡G¦¹®É§Ú¿é¤JÃöª`LÄæ¦ì
«h·|¥h¤ñ¸û¤¸¥óCªºLÄæ¦ì¡A¸ò¤¸¥óEªºLÄæ¦ì¤§¶¡¤j¤p¡AÅã¥Ü¥X¤jªº¼Æ­È

²Ä¤TÃD·Q§e²{ªºµ²ªG
¤ñ¸ûZÄæ¦ìªº¤j¤p¡A¿ï¾Ü³Ì¤pªº

TOP

¦^´_ 5# joey77373
  1. Public Rng As Range
  2. Sub ²Ä¤@ÃD()
  3.     Dim myInput, i As Integer, Ar As Variant, MyMax#, MyStr
  4.     Dim Str As String, Dic As Object
  5.     myInput = InputBox("½Ð¿é¤JÁ`¦¾¬VªùÂe­È(%):")
  6.     Set Dic = CreateObject("Scripting.Dictionary")
  7.     For i = 2 To 9
  8.     If Not IsNumeric(Cells(i, 9)) Then MsgBox "I" & i & "½Ð¿é¤J¼Æ¦r": Exit Sub
  9.       If Cells(i, 9) >= (myInput / 1) Then
  10.          Dic(Cells(i, 1).Value) = Array(Cells(i, 9), Cells(i, 1))
  11.          If Rng Is Nothing Then Set Rng = Cells(i, "L").Resize(, 6) Else Set Rng = Union(Rng, Cells(i, "L").Resize(, 6))
  12.       End If
  13.     Next i
  14.     If Dic.Count = 0 Then MsgBox "¨S¦³²Å¦X±ø¥óªº¤¸¥ó": Set Rng = Nothing: Exit Sub
  15.     TestStr = Join(Dic.keys, ",")
  16.     Do Until Dic.Count = 0
  17.      Ar = Application.Transpose(Application.Transpose(Dic.items))
  18.      MyMax = Application.Max(Application.Index(Ar, , 1))
  19.      MyStr = Application.VLookup(MyMax, Ar, 2, 0)
  20.      MsgBox "¤¸¥ó  " & MyStr & "  " & MyMax
  21.      Dic.Remove MyStr
  22.     Loop
  23. End Sub
  24. Sub ²Ä¤GÃD()
  25. Dim MyMax#, MyStr$, MyTital$, MyCol%, Rw As Range
  26. If Rng Is Nothing Then MsgBox "¥¼¦³²Å¦X¤§¤¸¥ó¡A½Ð¥ý°õ¦æ²Ä¤@ÃD": Exit Sub
  27. If Application.Count(Rng) <> Rng.Count Then MsgBox Rng.SpecialCells(xlCellTypeConstants, 2).Address & "¬°«D¼Æ­È¸ê®Æ": Exit Sub
  28. MyCol = InputBox("·Å«Ç®ÄÀ³%¼Æ=1" & Chr(10) & "¯ä®ñ®ø¯Ó%¼Æ=2" & Chr(10) & "»Ä¤Æ%¼Æ=3" & Chr(10) & "Àu¾i¤Æ%¼Æ=4" & Chr(10) & "­«ª÷ÄÝ%¼Æ=5" & Chr(10) & "­PÀù©Ê%¼Æ=6", "½Ð¿é¤JÄæ¦ì", 1)
  29. For Each Rw In Rng.Rows
  30.    If Rw.Cells(MyCol) > MyMax Then MyMax = Rw.Cells(MyCol): MyStr = Cells(Rw.Row, 1)
  31. Next
  32. MsgBox "¤¸¥ó  " & MyStr & "  " & Format(MyMax, "0.00%")
  33. End Sub
  34. Sub ²Ä¤TÃD()
  35. Dim MyMax#, MyStr$, MyTital$, MyCol%
  36. If Application.Count([Z2:Z4]) <> [Z2:Z4].Count Then MsgBox [Z2:Z4].SpecialCells(xlCellTypeConstants, 2).Address & "¬°«D¼Æ­È¸ê®Æ": Exit Sub
  37. MyMax = Application.Min([Z2:Z4])
  38. k = Application.Match(MyMax, [Z2:Z4], 0)
  39. MsgBox "¤¸¥ó  " & [S1].Offset(k) & " Á`¦¾¬VÅv­«­È " & MyMax
  40. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 6# Hsieh


·PÁÂHsieh´£¨Ñ¡A­è­è¿é¤J©óExcel¤¤run«á¡A¨t²Îª½±µ¥X²{¤¸¥óC-2Á`¦¾¬VÅv­«­È32.62

¹Lµ{¸ß°Ýµøµ¡¨S¦³¥X²{¡A¤£ª¾¹D¬O¤£¬O²Ä¤GÃD³¡¤Àªº°ÝÃD¡C

TOP

¦^´_ 7# joey77373
«e¨â­Ó°ÝÃD¬O§_¦³¹F¨ì§Aªº»Ý¨D?
²Ä¤T­Ó°ÝÃD¤´µM¬Ý¤£¥X»P«e¨â­Ó°ÝÃDªºÃöÁp©Ê
¬Oª½±µ¨ú±o³Ì¤p­È¨q¥X¡A»P«e­±ªº¿z¿ïµLÃö
­Y§Aªº»Ý¨D¨Ã¤£¬O¦p¦¹¡A½Ð¸Ô­z¨ä»P«e¨â­Ó°ÝÃDªºÃöÁp©Ê
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¥»©«³Ì«á¥Ñ joey77373 ©ó 2013-6-4 20:32 ½s¿è

¦^´_ 8# Hsieh

©êºpHsieh¤j¡AÀ³¸Ó¬O§Ú´y­zªº°ÝÃD¡A§Ú²Ä¤T­Ó°ÝÃDªºªí®æÅܰʤF¤@¤U³o¼Ë¤ñ¸û¦n´y­z§Úªº°ÝÃD

»P²Ä¤GÃDªºÃöÁp©Ê¬O¡A·íµ²ªGÅã¥Ü"C¤¸¥ó"·Å«Ç®ÄÀ³%¼Æ³Ì°ª"

©Ò¥H±q²Ä¤TÃDªº¤¸¥ó¸ê®Æ¤¤´M§ä"C"ªº´À¥N¤¸¥ó(SÄæ¦ì)¡A±q¸ê®Æ¥i¥H¬Ý¨ìC¦³4­Ó´À¥N¤¸¥ó(C-1¡BC-2¡BC-3¡BC-4)

µM«á¥ý¤ñ¸û´À¥N¤¸¥óªº"·Å«Ç®ÄÀ³"(TÄæ¦ì)ªº­È¦³¨S¦³¤ñ­ì¥»ªº°ª¡A°ªªº±Æ¥X(C-3¡BC-4)

³Ñ¤Uªº´À¥N¤¸¥ó(C-1¡BC-2)¡A´M§ä"Á`¦¾¬VÅv­«­È"(ZÄæ¦ì)¤ñ¸ûC-1»PC-2¿ï¾Ü¸û¤pªº­È¬°µª®×¡C

½d¨Ò¸ê®Æ.rar (12.18 KB)

TOP

¦^´_ 9# joey77373
¬O³o¼Ë¶Ü?
  1. Public Rng As Range, MyMaxNum#, MyCol%, MyStr$
  2. Sub ²Ä¤@ÃD()
  3.     Dim myInput, i As Integer, Ar As Variant, MyMax# ', MyStr
  4.     Dim Str As String, Dic As Object
  5.     myInput = InputBox("½Ð¿é¤JÁ`¦¾¬VªùÂe­È(%):")
  6.     Set Dic = CreateObject("Scripting.Dictionary")
  7.     For i = 2 To 9
  8.     If Not IsNumeric(Cells(i, 9)) Then MsgBox "I" & i & "½Ð¿é¤J¼Æ¦r": Exit Sub
  9.       If Cells(i, 9) >= (myInput / 1) Then
  10.          Dic(Cells(i, 1).Value) = Array(Cells(i, 9), Cells(i, 1))
  11.          If Rng Is Nothing Then Set Rng = Cells(i, "L").Resize(, 6) Else Set Rng = Union(Rng, Cells(i, "L").Resize(, 6))
  12.       End If
  13.     Next i
  14.     If Dic.Count = 0 Then MsgBox "¨S¦³²Å¦X±ø¥óªº¤¸¥ó": Set Rng = Nothing: Exit Sub
  15.     TestStr = Join(Dic.keys, ",")
  16.     Do Until Dic.Count = 0
  17.      Ar = Application.Transpose(Application.Transpose(Dic.items))
  18.      MyMax = Application.Max(Application.Index(Ar, , 1))
  19.      MyStr = Application.VLookup(MyMax, Ar, 2, 0)
  20.      MsgBox "¤¸¥ó  " & MyStr & "  " & MyMax
  21.      Dic.Remove MyStr
  22.     Loop
  23. End Sub
  24. Sub ²Ä¤GÃD()
  25. Dim MyTital$, Rw As Range
  26. If Rng Is Nothing Then MsgBox "¥¼¦³²Å¦X¤§¤¸¥ó¡A½Ð¥ý°õ¦æ²Ä¤@ÃD": Exit Sub
  27. If Application.Count(Rng) <> Rng.Count Then MsgBox Rng.SpecialCells(xlCellTypeConstants, 2).Address & "¬°«D¼Æ­È¸ê®Æ": Exit Sub
  28. MyCol = InputBox("·Å«Ç®ÄÀ³%¼Æ=1" & Chr(10) & "¯ä®ñ®ø¯Ó%¼Æ=2" & Chr(10) & "»Ä¤Æ%¼Æ=3" & Chr(10) & "Àu¾i¤Æ%¼Æ=4" & Chr(10) & "­«ª÷ÄÝ%¼Æ=5" & Chr(10) & "­PÀù©Ê%¼Æ=6", "½Ð¿é¤JÄæ¦ì", 1)
  29. For Each Rw In Rng.Rows
  30.    If Rw.Cells(MyCol) > MyMaxNum Then MyMaxNum = Rw.Cells(MyCol): MyStr = Cells(Rw.Row, 1)
  31. Next
  32. MsgBox "¤¸¥ó  " & MyStr & "  " & Format(MyMaxNum, "0.00%")
  33. End Sub
  34. Sub ²Ä¤TÃD()
  35. Dim A As Range, Temp#
  36. Set A = [S:S].Find(MyStr, lookat:=xlWhole)
  37. Temp = A.Offset(, 7)
  38. Do Until Left(A, 1) <> MyStr
  39.   If A.Offset(, MyCol) <= MyMaxNum Then
  40.      If A.Offset(, 7) <= Temp Then Temp = A.Offset(, 7): Ch = A: Test = A.Offset(, MyCol)
  41.   End If
  42.   Set A = A.Offset(1)
  43. Loop
  44. MsgBox "´À¥N¤¸¥ó " & Ch & [S1].Offset(, MyCol) & "­È= " & Test & "Á`¦¾¬VÅv­«­È= " & Temp
  45. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

        ÀR«ä¦Û¦b : ¤@­Ó¤Hªº§Ö¼Ö¡D¤£¬O¦]¬°¥L¾Ö¦³±o¦h¡A¦Ó¬O¦]¬°¥L­p¸û±o¤Ö¡C
ªð¦^¦Cªí ¤W¤@¥DÃD