Detectiveclem
Active Member
- Joined
- May 31, 2014
- Messages
- 320
- Office Version
- 365
- 2016
- Platform
- Windows
- MacOS
Can anyone explain why I get a Run-time error '91' when trying to use the following code.
I want my Macro is simply remove unwanted text in a cell and leave whatever text is left. Below you will see that I wish the 'LAST NAME' to be removed but leave the remaining text.
Any help would be greatly appreciated.
Sub Macro22()
'
' Macro22 Macro
'
' Keyboard Shortcut: Ctrl+t
'
Range("D2").Select
ActiveCell.Replace What:="LAST NAME ", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Find(What:="LAST NAME ", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=True, SearchFormat:=False).Activate
Range("H2").Select
ActiveCell.Replace What:="NAME OF SIPP", Replacement:="", LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Find(What:="NAME OF SIPP", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=True, SearchFormat:=False).Activate
Range("I2").Select
ActiveCell.Replace What:="SIPP REF", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Find(What:="SIPP REF", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=True, SearchFormat:=False).Activate
End Sub
I want my Macro is simply remove unwanted text in a cell and leave whatever text is left. Below you will see that I wish the 'LAST NAME' to be removed but leave the remaining text.
Any help would be greatly appreciated.
Sub Macro22()
'
' Macro22 Macro
'
' Keyboard Shortcut: Ctrl+t
'
Range("D2").Select
ActiveCell.Replace What:="LAST NAME ", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Find(What:="LAST NAME ", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=True, SearchFormat:=False).Activate
Range("H2").Select
ActiveCell.Replace What:="NAME OF SIPP", Replacement:="", LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Find(What:="NAME OF SIPP", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=True, SearchFormat:=False).Activate
Range("I2").Select
ActiveCell.Replace What:="SIPP REF", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Find(What:="SIPP REF", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=True, SearchFormat:=False).Activate
End Sub