我对VBA,这个论坛和一般编程非常新颖。我有一个工作表,我已经设法谷歌和调整某些代码行按我的要求。将多个子插件组合成一个VBA子集
我的问题是我总共有三个潜艇,并且必须逐步运行每个VBA脚本。我希望将所有三个VBA脚本合并为一个。 (步骤1 +步骤2 +步骤3 =全部在一个小组中)
您能否告诉我如何将这些多个VBA脚本或Subs组合在一个单独的sub的umbrealla下,以便我只需运行VBA脚本一次而不是三次。
'---------Step1----------------------------------------
'----Run the macro press F5-----
'========================================================================
' DELETES ALL ROWS FROM F DOWNWARDS WITH THE WORDs " " IN COLUMN F
'========================================================================
Sub DeleteRowWithContents()
Last = Cells(Rows.Count, "F").End(xlUp).Row
For i = Last To 1 Step -1
If (Cells(i, "F").Value) = "Ja" Or (Cells(i, "F").Value) = "Unbearbeitet" Or (Cells(i, "F").Value) = "-" Or (Cells(i, "F").Value) = "" Then
'Cells(i, "A").EntireRow.ClearContents ' USE THIS TO CLEAR CONTENTS BUT NOT DELETE ROW
Cells(i, "A").EntireRow.Delete
End If
Next i
End Sub
'-------------------------------Step 2--------------------
'---Run the macro, press F5. The macro compares the row contents in column A and if found a match deletes one of the results--
Sub btest()
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 2 Step -1
If Range("A" & i).Value = Range("A" & i - 1).Value Then Rows(i).Delete
Next i
End Sub
'-----------------Step 3---------
'--------Delete Unwanted Columns and adjust the column width----
Sub sbVBS_To_Delete_EntireColumn_For_Loop()
Dim iCntr
Dim kCntr
Dim jCntr
For iCntr = 1 To 4 Step 1
Columns(2).EntireColumn.Delete '-----Del unwanted columns----
Next
For kCntr = 1 To 3 Step 1
Columns(3).EntireColumn.Delete
Next
For jCntr = 1 To 8 Step 1
Columns(4).EntireColumn.Delete
Next
ActiveSheet.Columns("A").Columnwidth = 20 '----Adjust Column width---
ActiveSheet.Columns("C").Columnwidth = 25
ActiveSheet.Columns("E").Columnwidth = 25
End Sub