В основном, что я пытаюсь сделать здесь, это использовать эту подпрограмму:
Sub SelectFirstBlankCell()
Dim sourceCol As Integer, rowCount As Integer, currentRow As Integer
Dim currentRowValue As String
sourceCol = ActiveCell.Column 'Uses ActiveCell.Column as reference now, but needs to fit into each Subroutine to select next available
rowCount = Cells(Rows.Count, sourceCol).End(xlUp).Row
'for every row, find the first blank cell and select it
For currentRow = 1 To rowCount
currentRowValue = Cells(currentRow, sourceCol).Value
If IsEmpty(currentRowValue) Or currentRowValue = "" Then
Cells(currentRow, sourceCol).Select
Exit For
End If
Next
End Sub
Чтобы найти следующую пустую ячейку в столбце для ввода строки из этой подпрограммы.
Set selRange = Selection
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
If strApps = "" Then
strApps = ListBox1.List(i)
intAppCodeOffset = i
strAppCodeVal = Worksheets("TestSheet").Range("B31").Offset(i, 0).Value
Else
strApps = strApps & ", " & ListBox1.List(i)
intAppCodeOffset = i
strAppCodeVal = strAppCodeVal & ", " & Worksheets("TestSheet").Range("B31").Offset(i, 0).Value
End If
End If
Next
Set selRange = selRange.Offset(1, 0)
With selRange
selRange.Value = strAppCodeVal
End With
Я пытался заменить selRage.Offset(1, 0)
на SelectFirstBlankCell
, но каждый раз получаю ошибку ссылки на объект.Любая помощь будет принята с благодарностью, так как я не могу найти здесь, как это сделать.