ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Old macro breaks! (https://www.excelbanter.com/excel-programming/333984-old-macro-breaks.html)

davegb

Old macro breaks!
 
I've been running a series of macros without problems for months. When
I made some major modifications to another macro in the same project,
all these macros stopped working, even though the macro I was modifying
and these macros don't call or relate to each other. The only
connection is that they use the same range and varable name for that
range.

Sub Top10()

ActiveSheet.Range("rFltrRng").AdvancedFilter
Action:=xlFilterInPlace, CriteriaRange:= _
Range("Z1:Z2"), Unique:=False
Range("a1").Select

End Sub

I've tried using a different name for "rFltrRng" to separate it from
the other variable in the other macro.
Any ideas?
Thanks


Tom Ogilvy

Old macro breaks!
 
rFltrRng isn't a variable. It is a string constant. Used in the context
you present, it represents the name of a range in Insert=Name=Define.

You need to go to Insert=Name=Define and see what the current refers to
Range definition is. If it isn't what you expect, then you need to figure
out how it is getting changed.

--
Regards,
Tom Ogilvy

"davegb" wrote in message
oups.com...
I've been running a series of macros without problems for months. When
I made some major modifications to another macro in the same project,
all these macros stopped working, even though the macro I was modifying
and these macros don't call or relate to each other. The only
connection is that they use the same range and varable name for that
range.

Sub Top10()

ActiveSheet.Range("rFltrRng").AdvancedFilter
Action:=xlFilterInPlace, CriteriaRange:= _
Range("Z1:Z2"), Unique:=False
Range("a1").Select

End Sub

I've tried using a different name for "rFltrRng" to separate it from
the other variable in the other macro.
Any ideas?
Thanks




STEVE BELL

Old macro breaks!
 
Do you have "Option Explicit" at the top of your macro modules?
This forces Excel to alert you when there are certain problems with your
code:
variables that are not recognized; variables not defined correctly, etc.

Please supply more info on the nature of the any errors that come up.
Type, line of code(s) that fails, etc...

--
steveB

Remove "AYN" from email to respond
"davegb" wrote in message
oups.com...
I've been running a series of macros without problems for months. When
I made some major modifications to another macro in the same project,
all these macros stopped working, even though the macro I was modifying
and these macros don't call or relate to each other. The only
connection is that they use the same range and varable name for that
range.

Sub Top10()

ActiveSheet.Range("rFltrRng").AdvancedFilter
Action:=xlFilterInPlace, CriteriaRange:= _
Range("Z1:Z2"), Unique:=False
Range("a1").Select

End Sub

I've tried using a different name for "rFltrRng" to separate it from
the other variable in the other macro.
Any ideas?
Thanks




davegb

Old macro breaks!
 

Thanks, Tom, that helped me track down the problem.

Tom Ogilvy wrote:
rFltrRng isn't a variable. It is a string constant. Used in the context
you present, it represents the name of a range in Insert=Name=Define.

You need to go to Insert=Name=Define and see what the current refers to
Range definition is. If it isn't what you expect, then you need to figure
out how it is getting changed.

--
Regards,
Tom Ogilvy

"davegb" wrote in message
oups.com...
I've been running a series of macros without problems for months. When
I made some major modifications to another macro in the same project,
all these macros stopped working, even though the macro I was modifying
and these macros don't call or relate to each other. The only
connection is that they use the same range and varable name for that
range.

Sub Top10()

ActiveSheet.Range("rFltrRng").AdvancedFilter
Action:=xlFilterInPlace, CriteriaRange:= _
Range("Z1:Z2"), Unique:=False
Range("a1").Select

End Sub

I've tried using a different name for "rFltrRng" to separate it from
the other variable in the other macro.
Any ideas?
Thanks



davegb

Old macro breaks!
 


STEVE BELL wrote:
Do you have "Option Explicit" at the top of your macro modules?


Yes

This forces Excel to alert you when there are certain problems with your
code:
variables that are not recognized; variables not defined correctly, etc.

Please supply more info on the nature of the any errors that come up.
Type, line of code(s) that fails, etc...

Thanks for the help, Steve!



All times are GMT +1. The time now is 03:44 AM.

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