#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Replace

I have a macro that does a filter on Column L for Sale Rep "Joe" and
then tries to replace the values in Column A. The problem is that is
replaces all instances in Column A, not just the filtered, or visible cells.

I tried this macro, an some variations, but have not had any success:

Sub UpdateCustType()

Dim mycell As Range
Dim myrng As Range

Set myrng = Range("L2", Selection.End(xlDown)) 'Loop through Sales Reps
For Each mycell In myrng
If Cell.Value = "Joe" Then
Cell.Offset(0, -11).Value = "Ind Contractor"
End If
Next mycell

End Sub

Any help would be appreciated

Thanks,

Scott

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Replace

The code you show shouldn't do anything except raise an error since CELL is
not initialized.

Sub UpdateCustType()

Dim mycell As Range
Dim myrng As Range

Set myrng = Range("L2", Range("L2").End(xlDown)) 'Loop through Sales Reps
For Each mycell In myrng
If lcase(myCell.Value) = "joe" Then
myCell.Offset(0, -11).Value = "Ind Contractor"
End If
Next mycell
End Sub

--
Regards,
Tom Ogilvy


"scott" wrote in message
...
I have a macro that does a filter on Column L for Sale Rep "Joe" and
then tries to replace the values in Column A. The problem is that is
replaces all instances in Column A, not just the filtered, or visible

cells.

I tried this macro, an some variations, but have not had any success:

Sub UpdateCustType()

Dim mycell As Range
Dim myrng As Range

Set myrng = Range("L2", Selection.End(xlDown)) 'Loop through Sales Reps
For Each mycell In myrng
If Cell.Value = "Joe" Then
Cell.Offset(0, -11).Value = "Ind Contractor"
End If
Next mycell

End Sub

Any help would be appreciated

Thanks,

Scott



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
Find and Replace - Replace with Blank Space Studebaker Excel Discussion (Misc queries) 4 April 3rd 23 10:55 AM
Can I replace a ' at the beginning of a text cell using Replace Hilde Excel Discussion (Misc queries) 4 September 10th 07 06:22 PM
Replace dialog should put focus on "Find What" not "Replace With" Michael Williams Excel Discussion (Misc queries) 0 May 24th 06 12:45 PM
find and replace - replace data in rows to separated by commas msdker Excel Worksheet Functions 1 April 15th 06 01:00 AM
How can I use replace(alt+H) for mutiple items needing replace Gery Excel Worksheet Functions 1 June 15th 05 05:51 PM


All times are GMT +1. The time now is 11:20 AM.

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

About Us

"It's about Microsoft Excel"