Конвертация из String в Integer:
1 |
i = CInt(s) |
Конвертация из Integer в String:
1 |
s = str(i) |
Активация конкретного листа:
1 |
sheets("mytabname").activate |
Использование циклов Do и выход из циклов:
1 2 3 4 5 6 7 8 9 10 11 12 |
Do [{While | Until} condition] [statements] [Exit Do] [statements] Loop Or, you can use this syntax: Do [statements] [Exit Do] [statements] Loop [{While | Until} condition] |
Процедура для удаления пустых строк
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
Private Sub CommandButton3_Click() 'Delete empty lines Dim numberOfRows, count As Integer Dim sheetName As String sheetName = TextBox3.Text Sheets(sheetName).Activate numberOfRows = CInt(TextBox1.Text) count = 0 For i = numberOfRows To 1 Step -1 If (Cells(i, 1).Value = Empty) Then count = count + 1 Cells(i, 1).EntireRow.Delete End If Next i MsgBox ("Finished. Number of deleted rows is" + Str(count)) End Sub |
Проверка того, что ячейка пуста и удаление целой строки:
1 2 3 4 |
If (Cells(i, 1).Value = Empty) Then count = count + 1 Cells(i, 1).EntireRow.Delete End If |
Показ сообщения с числом каким-нибудь:
1 |
MsgBox ("Finished. Number of deleted rows is" + Str(count)) |
Добавление данных на другой лист:
1 |
Worksheets("XProdRugSets").Cells(i + j - firstRugSetIDRow + 1, 1).Value = ProdID |