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

Excel VBA ¥Îtextbox·s¼Wªí³æ¸ê®Æ°ÝÃD

Excel VBA ¥Îtextbox·s¼Wªí³æ¸ê®Æ°ÝÃD

¤j®a¦n~

³Ìªñ¤~¶}©l¾Ç²ßVBA¡A·Q­n³]­ptextbox¨Ó·s¼Wªí³æ¸ê®Æ¡A¥Ø«e¼gªºµ{§Ç¥i¥H°õ¦æ¡A¦ý¬O³£·|»\±¼²Ä¤@¦Cªº¼ÐÃDÄæ¡A·Q½Ð°Ý¸Ó¦p¦ó­×§ï¤~¯àÅý¸ê®Æª½±µ±q²Ä¤G¦C¶}©l¨Ì§Ç©¹¤U·s¼W¡AÁÂÁÂ!


Book.zip (22 Bytes)

Book.zip (22 Bytes)

¦^´_ 1# Sofie

À£ÁYÀɤj¤p¥u¦³ 22 ­ÓBytes -----> ExcelÀɨS¥[¶i¨Ó, ½Ð­«À£«á¦A­«¶Ç¤W¨Ó.

TOP

­«·s¤W¶Çªþ¥ó¤F¡A·PÁ´£¿ô!

°õ¦æ«eªºªí®æ¡õ


°õ¦æ«áªºªí®æ¡õ¡]¼ÐÃD´N³QÂл\¤F¡A·Q­×§ï¦¨±q²Ä¤G¦C¶}©l·s¼W¸ê®Æ¡AÅ޿褣¤Ó¦n·Q¤£¥X¨Ó ¡^
  1. Option Explicit
  2. Public n As Integer
  3. Private Sub CommandButton1_Click()
  4. n = n + 1
  5.    
  6.     If Range("b" & n) <> "" Then

  7.    
  8.     Sheets("Sheet1").Range("b" & n).Value = TextBox1.Value
  9.    
  10.     End If
  11.      If Range("c" & n) <> "" Then

  12.    
  13.     Sheets("Sheet1").Range("c" & n).Value = TextBox2.Value
  14.    
  15.     End If
  16. End Sub
½Æ»s¥N½X
Book.zip (9.86 KB)

TOP

¦^´_ 3# Sofie


    Private Sub CommandButton1_Click()
n = Cells(ActiveSheet.Rows.Count, 2).End(xlUp).Row + 1 '©¹³Ì«á¦³¸ê®Æ¦C+1¶K¤W

   
    If Range("b" & n) = "" Then

   
    Sheets("Sheet1").Range("b" & n).Value = TextBox1.Value
   
    End If
     If Range("c" & n) = "" Then

   
    Sheets("Sheet1").Range("c" & n).Value = TextBox2.Value
   
    End If
End Sub

TOP

¦^´_ 4# starry1314

·PÁ¦^ÂÐ!

«á¨Ó§ÚÄ~Äò©µ¦ù°ÝÃD¡A·Q«ö¦~Ä֯ŶZ©ó¤£¦P°_©l¦C·s¼W¸ê®Æ¡A¤ñ¦p»¡¦~ÄÖ¤j©ó60·³ªº±q²Ä20¦C¶}©l·s¼W¡A
¨BÆJ1. key ±iXX  12
¨BÆJ2. key ªLOO 65
¨BÆJ3. keyªLOO 24
¦ý¬O·í¦~ÄÖ¤j©ó60ªº¸ê®Æ¶i¨Ó¤§«á¡A²Ä¤Tµ§¤p©ó60·³ªº¸ê®Æ´N·|¸òµÛ¨BÆJ3ªºµ²ªG©¹¤U·s¼W¡A¦Ó¤£¬O±q¨BÆJ1ªºµ²ªG©¹¤U¡A

·Q½Ð°Ý§Ú¤Ö§PÂ_¤F¤°»ò¦a¤è¡AÁÂÁÂ~
  1. Private Sub CommandButton1_Click()
  2.     n = Cells(ActiveSheet.Rows.Count, 2).End(xlUp).Row + 1 '©¹³Ì«á¦³¸ê®Æ¦C+1¶K¤W

  3.    
  4.     If Range("b" & n) = "" And TextBox2.Value > 60 Then
  5.    
  6.             
  7.          Sheets("Sheet1").Range("b" & 20 + n).Value = TextBox1.Value
  8.    
  9.    
  10.          Sheets("Sheet1").Range("c" & 20 + n).Value = TextBox2.Value
  11.          
  12.       Else
  13.          
  14.          Sheets("Sheet1").Range("b" & n).Value = TextBox1.Value
  15.    
  16.    
  17.          Sheets("Sheet1").Range("c" & n).Value = TextBox2.Value


  18.    
  19.     End If
  20.    
  21. End Sub
½Æ»s¥N½X

TOP

¦^´_ 5# Sofie
    If Range("B" & n) = "" And TextBox2.Value > 60 Then
    If Range("C" & n) = "" And TextBox2.Value > 60 Then

§PÂ_¦~ÄÖªº¦a¤è¿ù¤F....
±q20¦C¶}©l·s¼W..¨S·Q¨ì«ç»ò°µ
¦]¬°¥Ø«e¬O¥H²Ä20¦C+³Ì«á¤@¦CªºÁ`¦C¼Æ ©Ò¥H¤¤¶¡·|¤@ª½ªÅ«Ü¤j®æ

TOP

x = TextBox2.Value
    If x < 60 Then
        y = [B20].End(xlUp).Row + 1
    Else
        y = [B65536].End(xlUp).Row + 1
        If y < 20 Then y = 20
    End If
    Cells(y, 2) = x

TOP

  1. Option Explicit
  2. Public n As Integer
  3. Private Sub CommandButton1_Click()
  4.     If TextBox2.Value > 60 Then n = 20 Else n = 2
  5.     Do
  6.             If Cells(n, "B") = "" Then Exit Do
  7.             n = n + 1
  8.     Loop
  9.     Sheets("Sheet1").Cells(n, "B").Value = TextBox1.Value
  10.     Sheets("Sheet1").Cells(n, "C").Value = TextBox2.Value
  11. End Sub
½Æ»s¥N½X
{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

TOP

¦^´_ 6# starry1314

¦^´_ 7# koo

¦^´_ 8# ML089

·PÁ¦U¦ì«e½úªº¤À¨É¡A¥Ø«e¨Ï¥Îkoo¤jªº¤èªk¥i¦æ!

TOP

        ÀR«ä¦Û¦b : ªY½à§O¤H´N¬O²øÄY¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD