ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Debug Error in Code (https://www.excelbanter.com/excel-discussion-misc-queries/143228-debug-error-code.html)

Karen McKenzie

Debug Error in Code
 
I have the following code which works fine when I import information into a
spreadsheet on my PC but which creates run time errors when replacing Overall
Result with "" when used by someone else. I think we are working on
different versions of Excel. Is there some modification of the code required
for it to run in versions earlier than 2003?

Private Sub Worksheet_Change(ByVal Target As Range)


Columns("A:A").Select
Selection.Replace What:="Overall Result", Replacement:="", LookAt:=xlPart _
, SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("A65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Select
Target.EntireColumn.AutoFit

End Sub




gert_lush

Debug Error in Code
 
Hi Karen

I've had similar problems when i was using a macro that originated from 2003
on XP. I removed the SearchFormat:=False part of the macro and it worked
fine on both versions of excel.
Hope this helps.

"Karen McKenzie" wrote:

I have the following code which works fine when I import information into a
spreadsheet on my PC but which creates run time errors when replacing Overall
Result with "" when used by someone else. I think we are working on
different versions of Excel. Is there some modification of the code required
for it to run in versions earlier than 2003?

Private Sub Worksheet_Change(ByVal Target As Range)


Columns("A:A").Select
Selection.Replace What:="Overall Result", Replacement:="", LookAt:=xlPart _
, SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("A65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Select
Target.EntireColumn.AutoFit

End Sub




Dave Peterson

Debug Error in Code
 
Check your other post, too.

Karen McKenzie wrote:

I have the following code which works fine when I import information into a
spreadsheet on my PC but which creates run time errors when replacing Overall
Result with "" when used by someone else. I think we are working on
different versions of Excel. Is there some modification of the code required
for it to run in versions earlier than 2003?

Private Sub Worksheet_Change(ByVal Target As Range)

Columns("A:A").Select
Selection.Replace What:="Overall Result", Replacement:="", LookAt:=xlPart _
, SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("A65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Select
Target.EntireColumn.AutoFit

End Sub


--

Dave Peterson


All times are GMT +1. The time now is 05:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com