VBA delete entire row with number (variable of For

2020-05-01 18:54发布

I'm struggling with a very basic issue:

Public Sub Optionfilter()
'Dim c As Range
Dim StrikeD As Date
Dim RefD As Date
Dim StrikeP As Integer
Dim S As Range
Dim R As Range
Dim XVAR As Integer
Dim Intervall As String
Dim Number As Integer
Dim TotalRow As Integer
Dim L As Integer
For Each S In ThisWorkbook.Worksheets("Data").Range("J6:J" & ThisWorkbook.Worksheets("Data").UsedRange.SpecialCells(xlCellTypeLastCell).Row)
If ThisWorkbook.Worksheets("Data").UsedRange.Cells(S.Row, S.Column + 1).Value > XVAR Then
        Debug.Print S.Row
        L = S.Row
        **ThisWorkbook.Worksheets("Data").Rows(L).Delete
        ThisWorkbook.Worksheets("Data").Rows("S.Row").Delete
        ThisWorkbook.Worksheets("Data").Range(S, 1).EntireRow.Delete**
else
end if
next S
end sub

I just want to delete the entire row with with the number coming for the loop (s.row) depending on the upper condition and everything works fine besides the actuall deleting of this row

标签: excel vba
0条回答
登录 后发表回答