X-O
06-08-2010, 03:46 PM
Hi, I need some help with a macro.
I have a template, but sometimes I don't need some sheets and I have to delete them. This converts some formulas like:
sheet1!A1+sheet2!A1+sheet3!A1
into
sheet1!A1+#¡REF!A1+sheet3!A1
I recorded a macro with "search and replace" to delete the "#¡REF" links, and I get this code, but It doesn't work if I run it directly as a macro.
Cells.Replace What:="+#¡REF!????+", Replacement:="+", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="+#¡REF!???+", Replacement:="+", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="+#¡REF!????", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="+#¡REF!???", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
I dunno if the '?' symbols doesn't work in the macro code, or if something else is needed to get a functional macro.
Any suggestion?
I have a template, but sometimes I don't need some sheets and I have to delete them. This converts some formulas like:
sheet1!A1+sheet2!A1+sheet3!A1
into
sheet1!A1+#¡REF!A1+sheet3!A1
I recorded a macro with "search and replace" to delete the "#¡REF" links, and I get this code, but It doesn't work if I run it directly as a macro.
Cells.Replace What:="+#¡REF!????+", Replacement:="+", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="+#¡REF!???+", Replacement:="+", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="+#¡REF!????", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="+#¡REF!???", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
I dunno if the '?' symbols doesn't work in the macro code, or if something else is needed to get a functional macro.
Any suggestion?