0
Sub CheckBox7_Click()

   Dim cBox As CheckBox
   Dim LRow As Integer
   Dim LRange As String

   LName = Application.Caller
   Set cBox = ActiveSheet.CheckBoxes(LName)

   'Find row that checkbox resides in
   LRow = cBox.TopLeftCell.Row
   LRange = "B" & CStr(LRow)

   'Change text in column b, if checkbox is checked
   If cBox.Value > 0 Then
      ActiveSheet.Range(LRange).Value = "3300-0401"

   'Clear text in column b, if checkbox is unchecked
   Else
      ActiveSheet.Range(LRange).Value = Null
   End If

End Sub

b15 から b40 までの最初の使用可能なセルに値 3300-0401 を入力する必要があります。また、この日付は文字列のどこに入力されますか?

ありがとう、ジャン

4

1 に答える 1

0

以下を使用して、範囲 B15:B40 の最初の空白セルに書き込むことができます。

Sub WriteToFirstAvailableCellInRange()
    Dim wb As Workbook
    Dim ws As Worksheet
    Dim firstEmptyCell As Range

    Set wb = ThisWorkbook
    Set ws = wb.Sheets("Sheet1")
    If ws.Range("B15").Value = "" Then
        Set firstEmptyCell = ws.Range("B15")
    Else
        If ws.Range("B16").Value = "" Then
            Set firstEmptyCell = ws.Range("B16")
        Else
            Set firstEmptyCell = ws.Range("B15").End(xlDown).Offset(1)
        End If
    End If

    If firstEmptyCell.Row < 41 Then
        firstEmptyCell.Value = "3300-0401"
    Else
        MsgBox "There aren't any empty cells in range B15:B40."
    End If
End Sub
于 2013-06-18T20:30:57.927 に答える