Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Liz Liz is offline
external usenet poster
 
Posts: 133
Default Replace method problems


Hi folks

I have a sub that should delete 3 from the strings in a selected range of
cells. It works for a single cell ( only if I if I include the
ActiveCell.Select line)

I get a message "Replace method of Range failed" with more than 1 cell
selected.

Please could anyone explain why it does not work with more than 1 selected
cell, and how I could get it to workfor a selection of cells?


Sub delete3()
Worksheets("Sheet1").Activate
'ActiveCell.Select
Selection.Replace What:="3", Replacement:="", LookAt:=xlPart,
SearchOrder:=xlByRows, MatchCase:=False
End Sub

Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Replace method problems

just modify the range to your needs

Sub delete3()
With Worksheets("Sheet1").Range("A1:F20")
..Replace What:="3", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
End With
End Sub


--


Gary


"Liz" wrote in message
...

Hi folks

I have a sub that should delete 3 from the strings in a selected range of
cells. It works for a single cell ( only if I if I include the
ActiveCell.Select line)

I get a message "Replace method of Range failed" with more than 1 cell
selected.

Please could anyone explain why it does not work with more than 1 selected
cell, and how I could get it to workfor a selection of cells?


Sub delete3()
Worksheets("Sheet1").Activate
'ActiveCell.Select
Selection.Replace What:="3", Replacement:="", LookAt:=xlPart,
SearchOrder:=xlByRows, MatchCase:=False
End Sub

Thanks




  #3   Report Post  
Posted to microsoft.public.excel.programming
Liz Liz is offline
external usenet poster
 
Posts: 133
Default Replace method problems

Thanks Gary

The problem is that the spreadsheet user is selecting cells on the
spreadsheet and it is this selection I need to use the replace method on.

Liz

"Gary Keramidas" wrote:

just modify the range to your needs

Sub delete3()
With Worksheets("Sheet1").Range("A1:F20")
..Replace What:="3", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
End With
End Sub


--


Gary



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Replace method problems

give this a try, just watch for word wrap


Sub delete3()
ActiveWorkbook.Names.Add Name:="test", RefersTo:="=" & ActiveSheet.Name & "!" &
_
ActiveWindow.RangeSelection.Address
With ActiveSheet.Range("test")
..Replace What:="3", Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, _
MatchCase:=False
End With
Range("test").Name.Delete
End Sub


--


Gary


"Liz" wrote in message
...
Thanks Gary

The problem is that the spreadsheet user is selecting cells on the
spreadsheet and it is this selection I need to use the replace method on.

Liz

"Gary Keramidas" wrote:

just modify the range to your needs

Sub delete3()
With Worksheets("Sheet1").Range("A1:F20")
..Replace What:="3", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
End With
End Sub


--


Gary





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
Replace method - cannot find any data to replace Mike Excel Programming 5 April 6th 06 08:56 PM
Problems with Protect Method AMK4[_2_] Excel Programming 8 January 17th 06 04:29 AM
Little problem with the REPLACE method. jase[_2_] Excel Programming 2 November 17th 05 01:53 PM
Problems with a method form multiple worksheets filo666 Excel Programming 1 July 14th 05 04:29 PM
Problems with Printout Method No Name Excel Programming 0 March 3rd 05 04:33 PM


All times are GMT +1. The time now is 12:21 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"