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

½Ð±Ðinputbox¦h­«¿é¤Jªº°ÝÃD¡C

½Ð±Ðinputbox¦h­«¿é¤Jªº°ÝÃD¡C

¦U¦ì¦n¡A½Ð±Ð¤@­Ó°ÝÃD¡G§Ú»Ý­n¦bexcel¸Ì­±¡A·í¨Ï¥ÎªÌÂI¿ï«ö¶s¤§«á¡A¸õ¥X¤@­Óµøµ¡¡A¸ß°Ý­þ¨âÃD­n¹ï´«¡A¨Ï¥ÎªÌ¿é¤J¨â­ÓÃD¸¹¤§«á¡Aµ{¦¡·|±N¨º¨âÃDªº¬Y¨Ç¯S©wÄæ¦ì¸ê®Æ¹ï´«¡C
Ä´¦pªþ¥ó©Ò¥Ü¡A«ö¤U¤@­Ó«ö¶s¡A¥X²{¤@­Óµøµ¡¡A¥X²{¡§¿é¤J¹ï´«ÃD¸¹¡¨¡A¨Ï¥ÎªÌ¿é¤J¡§3¡¨©M¡§5¡¨¡A´N·|§â¡§¤@¤G¤T¥|¤­¡¨(B4:F4)»P¡§¹«¤ûªê¨ßÀs¡¨(B6:F6)µ¹¹ï´«¡AÃD¸¹«hºû«ù¤£ÅÜ¡C

¦^´_ 1# tku0216
  1. Private Sub CommandButton1_Click()
  2. Dim i%, j%, a As Range, b As Range, ar(), ar1()
  3. i = InputBox("¿é¤JÃD¸¹1")
  4. j = InputBox("¿é¤JÃD¸¹2")
  5. Set a = Columns("A").Find(i, lookat:=xlWhole)
  6. Set b = Columns("A").Find(j, lookat:=xlWhole)
  7. If a Is Nothing Or b Is Nothing Then MsgBox "µL¦¹ÃD¸¹": Exit Sub
  8. ar = a.Offset(, 1).Resize(, 5).Value
  9. ar1 = b.Offset(, 1).Resize(, 5).Value
  10. a.Offset(, 1).Resize(, 5) = ar1
  11. b.Offset(, 1).Resize(, 5) = ar
  12. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

·PÁ¿½¤j¡A§Ú­è¤]¸Õ¥X¤F¤èªk
Private Sub CommandButton1_Click()
    Dim q1, q2 As Integer
    q1 = InputBox("¿é¤JÃD¸¹¤@") + 2 '¦]¬°§Úªº²Ä¤@ÃD¬O±q²Ä¤T¦C¶}©l
    q2 = InputBox("¿é¤JÃD¸¹¤G") + 2
    r1 = Range(Cells(q1, 3), Cells(q1, 15)) '±N¬YÃD²Ä3Äæ~²Ä15Ä檺¸ê®Æ¹ï´«
    r2 = Range(Cells(q2, 3), Cells(q2, 15))
    msgaa = MsgBox("½T»{²Ä" & q1 - 2 & "»P²Ä" & q2 - 2 & "ÃD¹ï´«?~~", 4)
    If msgaa = 6 Then  '­Y½T»{¹ï´«¡A«ö¤Uok
    Range(Cells(q2, 3), Cells(q2, 15)) = r1
    Range(Cells(q1, 3), Cells(q1, 15)) = r2
    End If
   
End Sub

TOP

¿½¤j±z¦n¡A
§Úµo²{±zªºµ{¦¡½X¡AÀ³¦b¾¹7»P8¦æ¤§¶¡¥[¤@­Óelse¡A§_«hµLªk°õ¦æ¡AÁÙ¦³¦ü¥G¨S¦³¥[¤Jend ifªº¸Ü¡Aµ{¦¡¤]µLªk°õ¦æ¡A¥i¥H½Ð°ÝÀ³¸Ó¥[¦b­þ¸Ì¶Ü¡H

TOP

¦^´_ 4# tku0216

  ¥H¤U´XºØifªº¨Ï¥Î¤è¦¡,¨Ñ§A°Ñ¦Ò~
  (H¤j¤jªº¼gªk~ ¨Ã¨S¦³°ÝÃD­ò~ )

    if   ±ø¥ó  then
         ²Å¦X±ø¥ó,°õ¦æµ²ªG
    end if

    if   ±ø¥ó  then
         ²Å¦X±ø¥ó,°õ¦æµ²ªG
    else
          ¤£²Å¦X±ø¥ó,°õ¦æµ²ªG
    end if

     if   ±ø¥ó1  then
         ²Å¦X±ø¥ó,°õ¦æµ²ªG
    elseif   ±ø¥ó2  then
          ²Å¦X±ø¥ó2,°õ¦æµ²ªG
     else
            ¤£²Å¦X±ø¥ó1»P¤£²Å¦X±ø¥ó2,°õ¦æµ²ªG
    end if

     if ±ø¥ó  then exit sub
¾Ç²ß¤~¯à´£¤É¦Û¤v

TOP

¥»©«³Ì«á¥Ñ c_c_lai ©ó 2012-7-27 15:24 ½s¿è

¦^´_ 3# tku0216
²Ä7¦æ¡B»P²Ä 8¦æ¬O¨â­Ó¤£¦PÅ骺±Ô­z¡C°£«D¬O§A±N If ±Ô­z¼g¦¨¡G
If a Is Nothing Or b Is Nothing Then
    MsgBox "µL¦¹ÃD¸¹"
    Exit Sub
End If
¥t¥~§Ú¬°¤F¦Û§Ú´ú¸Õ¡A µy¥[­×§ï¤F i%, j% ªº«Å§i¤è¦¡¡G
    ' Dim i%, j%, a As Range, b As Range, ar(), ar1()
    Dim i, j, a As Range, b As Range, ar(), ar1()
   
    i = InputBox("¿é¤JÃD¸¹1")    ' i% ¦pªG¿é¤J­È¬° a¡A«h·|¥X²{«¬ºA¤£²Åªº¿ù»~°T®§
    j = InputBox("¿é¤JÃD¸¹2")    ' j ¤¹³\¿é¤J¥ô¦ó¼Æ­È¡B¦r¤¸©Î¦r¦ê

TOP

ÁÙ¦³·Q½Ð±Ð¡Ainputboxªº³¡¤À¡A¦pªG·QÅý¨Ï¥ÎªÌ¿é¤J«D¼Æ¦r®É¡A§YÅã¥Ü¿ù»~°T®§¦Ó­n¨D­«·s¿é¤J¡A§Ú¬Ýºô¸ô¤Wªº°µªk¬O¥Îapplication.inputbox¤èªk¡A¦ý­Y­n¥[¤J¨Ï¥ÎªÌ¥i¥HÂI¿ïcancel®É¡Aµ{¦¡ÀH§Y¸õ¥X¡A½Ð°ÝÀ³¸Ó¦p¦ó³B¸Ì¡H

TOP

¦^´_ 7# tku0216


    i = Application.InputBox("½Ð¿é¤J¼Æ­È", "¿é¤J¼Æ­È", 1, , , , , 1)
If i = False Then MsgBox "¤w¨ú®ø¿é¤J": Exit Sub Else MsgBox "¿é¤J¼Æ­È¬°" & i
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

        ÀR«ä¦Û¦b : ½_ÁJµ²±o¶V¹¡º¡¡A¶V·|©¹¤U««¡A¤@­Ó¤H¶V¦³¦¨´N¡A´N­n¶V¦³Á¾¨Rªº¯ÝÃÌ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD