Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Prior macro not working in new location after some alterations

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default Prior macro not working in new location after some alterations

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)


"William" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro - save to current location vs excel default location leezard Excel Discussion (Misc queries) 0 October 28th 08 03:04 PM
How do I run a macro upon saving a file but prior to actual save? Hawk186 Excel Discussion (Misc queries) 2 June 6th 08 09:38 PM
trusted location for macros not working BorisS Excel Discussion (Misc queries) 0 April 25th 07 07:34 PM
default file location not working [email protected] Excel Discussion (Misc queries) 0 April 26th 06 03:22 PM
Refer to a Name saved prior my macro Starts from VBA excel [email protected] Excel Programming 1 January 21st 04 11:47 AM


All times are GMT +1. The time now is 11:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"