I have the following code that works great inside my excel workbook. However, the spreadsheet where this script resides is about to be converted into a shared workbook and I will be unable to use macros in it. I was looking at using a stand-alone script outside excel to modify the workbook but I have run into issues.
Following is the code I have in excel:
Sub moveMatches()
Dim myrng As Range, i As Long
Application.ScreenUpdating = 0
With Sheets("REQUESTER")
For i = 9 To .Cells(.Rows.Count, "DP").End(xlUp).Row
If .Cells(i, "DP") <> vbNullString And .Cells(i, "DQ") <> vbNullString _
And .Cells(i, "DR") <> vbNullString And .Cells(i, "DS") <> vbNullString And .Cells(i, "DT") <> vbNullString Then
If myrng Is Nothing Then
Set myrng = .Cells(i, "a")
Else
Set myrng = Union(myrng, .Cells(i, "a"))
End If
End If
Next i
End With
If Not myrng Is Nothing Then
With Worksheets("Completed").Cells(Rows.Count, "a").End(xlUp)
myrng.EntireRow.Copy .Offset(1)
End With
myrng.EntireRow.Delete
End If
Application.ScreenUpdating = True
End Sub
This is my start but I keep runnin into issues:
Set objExcel= CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open ("M:\Data Analytics\_Test Directory Structure\MM Change Register.xlsx")
objExcel.Application.Visible = True
Dim myrng As Range, i As Long
Application.ScreenUpdating = 0
With Sheets("REQUESTER")
For i = 9 To .Cells(.Rows.Count, "DP").End(xlUp).Row
If .Cells(i, "DP") <> vbNullString And .Cells(i, "DQ") <> vbNullString _
And .Cells(i, "DR") <> vbNullString And .Cells(i, "DS") <> vbNullString And .Cells(i, "DT") <> vbNullString Then
If myrng Is Nothing Then
Set myrng = .Cells(i, "a")
Else
Set myrng = Union(myrng, .Cells(i, "a"))
End If
End If
Next i
End With
If Not myrng Is Nothing Then
With Worksheets("Completed").Cells(Rows.Count, "a").End(xlUp)
myrng.EntireRow.Copy .Offset(1)
End With
myrng.EntireRow.Delete
End If
Application.ScreenUpdating = True
Any help/advise would be appreciated.
Thanks,
Met
Bookmarks