2016-03-05 53 views
0

我試圖輸出用戶窗體的文本框中的值將在列的下一個空單元格的下一個無細胞:VBA輸出組合框的值到

Private Sub CommandButton2_Click() 
     Dim LastRow As Long 
     With ThisWorkbook.Sheets("Output") 
      LastRow = .Cells(.Rows.Count, "H").End(xlUp).Row 
      With .Range("H" & LastRow) 
       .Value2 = TextBox1.Value 
      End With 
     End With 
End Sub 

但是,它不會工作並且我沒有收到任何錯誤消息。

任何想法,我錯了嗎?

感謝

回答

1

試一下這個*更改爲CommandButton2

 Private Sub CommandButton2_Click() 
    Dim LastRow As Long 
    With ThisWorkbook.Sheets("Output") 
    LastRow = Cells(.Rows.Count, "H").End(xlUp).Offset(1, 0).Row 
    Range("H" & LastRow).Value = TextBox1.Value 
    End With 
    End Sub