Runawaygeek
Registered User.
- Local time
- Today, 19:04
- Joined
- Mar 28, 2016
- Messages
- 77
Hi all,
I have a function that works sometimes, but other times gives me an error.
"Run-time error '1004
Method 'Rows' of object'_Global' Failed"
My function, opens Excel and then erases all the rows that meet a string value in a cell.
when is does work, it has this habit of making a hand full of cells set to their Max height, but thats a minor issues. I would love to solve the 1004 error.
My code is:
I have a function that works sometimes, but other times gives me an error.
"Run-time error '1004
Method 'Rows' of object'_Global' Failed"
My function, opens Excel and then erases all the rows that meet a string value in a cell.
when is does work, it has this habit of making a hand full of cells set to their Max height, but thats a minor issues. I would love to solve the 1004 error.
My code is:
Code:
Private Function WipeExcel()
Dim FN As String
Dim LN As String
Dim UN As String
FN = "VOD Ops "
LN = " Schedule.xlsx"
If IsNull(Me.Combo1) = True Then MsgBox "Choose a User", vbOKOnly + vbInformation, "No Selection": Exit Function
UN = Me.Combo1
Path = FN & UN & LN
Dim filepath_tracker As String
filepath_tracker = "C:\VOD Operations\" & Path 'This is to be the Tracker of the DPN VOD OP
Dim WB As Excel.Workbook
Dim xlApp As Excel.Application
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set WB = xlApp.Workbooks.Open(filepath_tracker, True, False)
Dim RD As Long
For RD = Range("AL" & Rows.Count).End(-4162).Row To 2 Step -1
If Range("AL" & RD).Value = "pulled" Or Range("AL" & RD).Value = "Delivered" Then
WB.Sheets(2).Rows(RD).EntireRow.Delete
End If
Next RD
End Function