Private Sub Add_Click()
Dim NextEmptyCol As Long
Dim ws As Worksheet
Set ws = Worksheets("ComboBoxList")
NextEmptyCol = Cells.Find("*", [A1], , , xlByColumns, xlPrevious).Column - 1
Row = ws.Cells.Find(What:="*", SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
ws.Cells(Row, 1).Value = Me.Response.Value
MsgBox "Column number " & NextEmptyCol & vbCr & _
"Or column letter """ & Replace(Cells(1, NextEmptyCol).Address(0, 0), 1, "") & """", _vbInformation, "The Next Empty Column is..."
End Sub
答案 0 :(得分:0)
目前还不是很清楚你想要什么,但我认为这可能会指出你正确的方向:
Sub foo()
Dim LastRow As Long
Dim LastCol As Long
LastCol = Worksheets("ComboBoxList").Cells(1, Worksheets("ComboBoxList").Columns.Count).End(xlToLeft).Column
'find the last column with data on row 1 (add 1 to this number to find the next empty column)
LastRow = Worksheets("ComboBoxList").Cells(Worksheets("ComboBoxList").Rows.Count, LastCol).End(xlUp).Row
'find the last row with data on the last column
Worksheets("ComboBoxList").Cells(LastRow + 1, LastCol).Value = Me.response.Value
'add the value of Response to the next empty row in the last column (empty row is lastrow with data +1)
End Sub