ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Feuding SORT - hasformula code (https://www.excelbanter.com/excel-programming/430362-feuding-sort-hasformula-code.html)

usmc-r70

Feuding SORT - hasformula code
 

The Part 1 code Will 'UNPROTECT' 'SORT' 'PROTECT' only when the Part 2 code
is NOT installed.
When Part 2 code is installed into another module, the 'Step' routine
'UNPROTECTS' and 'SORTS' properly, but fails to 'PROTECT'.
No error is disdisplayed when the macro is run.

What could be the conflict?

'PART 1
Option Explicit
Sub RANKING_SORT()
ActiveSheet.Unprotect
Dim source As Range
With ActiveSheet
Set source = .Range(.Range("A11"), .Range("AR11").End(xlDown))
End With
source.Sort source.Range("V11"), xlAscending
ActiveSheet.Protect
End Sub


'PART 2
Function HasFormula(c As Range) As Boolean
HasFormula = c.HasFormula
End Function

Patrick Molloy

Feuding SORT - hasformula code
 

its not wise to name your own functions and procedures the same as excel
object methods ... in this case you have a UDF called HasFormula which also
appies to a range object.
Change your function name

apart from this, you don't give enough information to assist further.

"usmc-r70" wrote in message
...
The Part 1 code Will 'UNPROTECT' 'SORT' 'PROTECT' only when the Part 2
code
is NOT installed.
When Part 2 code is installed into another module, the 'Step' routine
'UNPROTECTS' and 'SORTS' properly, but fails to 'PROTECT'.
No error is disdisplayed when the macro is run.

What could be the conflict?

'PART 1
Option Explicit
Sub RANKING_SORT()
ActiveSheet.Unprotect
Dim source As Range
With ActiveSheet
Set source = .Range(.Range("A11"), .Range("AR11").End(xlDown))
End With
source.Sort source.Range("V11"), xlAscending
ActiveSheet.Protect
End Sub


'PART 2
Function HasFormula(c As Range) As Boolean
HasFormula = c.HasFormula
End Function



usmc-r70

Feuding SORT - hasformula code
 

Patrick, thank you so very much for your replay! Your were exactly correct,
changed the name and everything works as planned. Again, Thanks!!!

"Patrick Molloy" wrote:

its not wise to name your own functions and procedures the same as excel
object methods ... in this case you have a UDF called HasFormula which also
appies to a range object.
Change your function name

apart from this, you don't give enough information to assist further.

"usmc-r70" wrote in message
...
The Part 1 code Will 'UNPROTECT' 'SORT' 'PROTECT' only when the Part 2
code
is NOT installed.
When Part 2 code is installed into another module, the 'Step' routine
'UNPROTECTS' and 'SORTS' properly, but fails to 'PROTECT'.
No error is disdisplayed when the macro is run.

What could be the conflict?

'PART 1
Option Explicit
Sub RANKING_SORT()
ActiveSheet.Unprotect
Dim source As Range
With ActiveSheet
Set source = .Range(.Range("A11"), .Range("AR11").End(xlDown))
End With
source.Sort source.Range("V11"), xlAscending
ActiveSheet.Protect
End Sub


'PART 2
Function HasFormula(c As Range) As Boolean
HasFormula = c.HasFormula
End Function




All times are GMT +1. The time now is 04:19 AM.

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