Prior macro not working in new location after some alterations

W

William

I have the following macro that does not work. I keep getting a error
message:
Run time error '424' object required
In WorkSheet2 I want to Loop thru column F from row 6 down to row 96
to find the text entries"early" that are randomly inserted, then
delete that text then move left 4 columns and select the next 3
columns to the left including the active cell. Copy the selected data
and then paste it into a preselected cell. The balance of the cells in
the col F are blank.
I use this macro in another location and it works just fine, but I
altered it a little to work in this new location, and I cannot seem to
make it work.

Sub Early_Late()
Application.ScreenUpdating = False
Range("A6").Activate

Set curCell = WorkSheet2.Cells(curRow,
1)
'Set current cell
While curCell.Value <> ""
If curCell.Value = "early" Then ActiveCell.Select
'If contains early, delete
Selection.Delete
Else
curRow = curRow + 1
'Move to next row
End If
Set curCell = Worksheets("WorkSheet2").Cells(curRow, 1)
'Reset current cell
Wend
Application.ScreenUpdating = True
End Sub
 
C

cush

try adding 3 lines of code as indicated below:

Sub Early_Late()

DIM curCell as Range '<<<<<Add
DIM curRow as Integer '<<<<Add

Application.ScreenUpdating = False
Range("A6").Activate
curRow=activecell.row '<<<<<Add
Set curCell = WorkSheet2.Cells(curRow,
1)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top