Hello,
I'm new to VBA and having trouble deleting a row. Error line =
I'm new to VBA and having trouble deleting a row. Error line =
ws2.Rows(x).Delete
Including the whole code below. Any ideas?
Including the whole code below. Any ideas?
Code:
Set ws1 = ThisWorkbook.Sheets("Ansatt")
Set ws2 = ThisWorkbook.Sheets("TabellAnsatt")
ws1.Range("Eksport").Copy
If ws1.Range("eksKontroll") = 1 Then
If ws2.Range("A2") <> "" Then
ws2.Range("A65536").End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
Else
ws2.Range("a2").PasteSpecial Paste:=xlPasteValues
End If
ElseIf ws1.Range("eksKontroll") = 2 Then
ws2.Range("A65536").End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
x = ws1.Range("eksRad")
ws2.Rows(x).Delete
End If
Application.CutCopyMode = False