1

言語 ID のチェックボックスがあるユーザー フォームがあります。オンにすると、ワークシート「出力」のセルが入力されます。コードは次のとおりです。

Private Sub btnSubmit_Click()

Sheets("output").Activate

NextRow = Application.WorksheetFunction.CountA(Range("A:A")) + 1
    If cbxEnUs Then Cells(NextRow, 3) = "3 - en-us"
    If cbxFr Then Cells(NextRow, 4) = "3 - fr"
    If cbxIt Then Cells(NextRow, 5) = "3 - it"

Sheets("input").Activate

次のデータ検証 (記録されたマクロから) を、値を受け取る各セルに適用したいと思います。

With Selection.Validation
    .Delete
    .Add Type:=xlValidateList, AlertStyle:=xlValidAlertInformation, _
    Operator:=xlBetween, Formula1:="3 - en-us,2 - en-us,1 - en-us"
    .IgnoreBlank = True
    .InCellDropdown = True
    .InputTitle = ""
    .ErrorTitle = "Incorrect value"
    .InputMessage = "3 = action req'd" & Chr(10) & "2 = in progress" & Chr(10) & "1 = complete"
    .ErrorMessage = "Please review valid input values" & Chr(10) & "and try again"
    .ShowInput = True
    .ShowError = True
End With

これら 2 つのコードを接続するにはどうすればよいですか?

4

1 に答える 1

1

Selection2 番目のコードを最初のコードとマージし、最初の行をCells(NextRow, 3)などに置き換えます。

IF ステートメントを複数の行に分割する必要があります。

If cbxEnUs Then 
    Cells(NextRow, 3) = "3 - en-us"
    ' apply validation to this cell
    With Cells(NextRow, 3).Validation
        'etc..
    End With
End if    'etc..
于 2013-07-02T17:01:21.163 に答える