返回列表 上一主題 發帖

[發問] UserForm表單相關問題

回復 6# v03586
試試看
  1. Option Explicit
  2. Private Sub CommandButton1_Click()
  3.     Dim Rng As Range, Ar(1 To 2), i As Integer
  4.     Ar(1) = Array(OptionButton1, OptionButton2, OptionButton3) ', OptionButton4, OptionButton5, OptionButton6....
  5.     Ar(2) = Array(TextBox1, TextBox2, TextBox3, TextBox4, TextBox5) ', TextBox6, TextBox7, TextBox8, TextBox9....
  6.    
  7.     'Join 函數 傳回一個字串,該字串是透過連結某個(一維)陣列中的多個子字串而建立的。
  8.     If InStr(UCase(Join(Ar(1), "")), "TRUE") = 0 Or InStr(Join(Ar(2), ","), ",,") Then
  9.         MsgBox ("資料未輸入完整, 『 * 』 必須輸入" & vbCrLf & _
  10.         "Data is not enter the full , 『 * 』 you must fill ")
  11.         Exit Sub
  12.     End If
  13.     ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  14.     Set Rng = Sheets("FMC Input Database").Range("a" & Rows.Count).End(xlUp).Offset(1)
  15.     With Rng  '物件Rng : 所指定的儲存格或儲存格範圍。(不必移動工作頁)
  16.         For i = 0 To UBound(Ar(1))
  17.             If Ar(1)(i).Value Then
  18.                 'Caption 屬性 出現在物件上的修飾文字 , 一般用來辨識或描述該物件
  19.                 .Value = Ar(1)(i).Caption
  20.                 Exit For
  21.                 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  22.             End If
  23.         Next
  24.         '.Range("B1")->這Rng 的 儲存格或儲存格範圍。
  25.         .Range("B1").Resize(, UBound(Ar(2)) + 1) = Ar(2)
  26.         .Range("G1") = Now
  27.         ''''''''''''''''''''''''''''''''''''''''''''
  28.     End With
  29. End Sub
複製代碼
感恩的心......(在麻辣家族討論區.用心學習會有進步的)
但資源無限,後援有限,  一天1元的贊助,人人有能力.

TOP

        靜思自在 : 一個人的快樂.不是因為他擁有得多,而是因為他計較得少。
返回列表 上一主題