ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   MACRO FUNCTION conflict with other macro's (https://www.excelbanter.com/excel-discussion-misc-queries/237346-macro-function-conflict-other-macros.html)

MrDave

MACRO FUNCTION conflict with other macro's
 
hi, don't know much about macro's, but the following (with slight
modification), seemed to work. the problem is that while this is installed,
example of next item below stops in the middle..

- to find if text exists in a formula: installed in a separate module

Option Explicit
Function FC(rng As Range, myStr As String) As Boolean
Set rng = rng.Cells(1)
FC = False
If rng.HasFormula Then
FC = CBool(InStr(1, rng.Formula, myStr, vbTextCompare) 0)
End If
End Function 'for: =FC(a1,"abc")


~~~~~~~~

example of what stops working:

If Range(testB1).Value = "AA" Then
Rows(hidaa).Select
Selection.EntireRow.Hidden = True
Range(hidrows).Select 'this portion does not execute from here down
Selection.ClearContents
Range(testB1).Select
Selection.ClearContents
End If


If have even the idea right, can I get this modified to insert a function
within a sub / under an option explicit, or does the top item need to be
modified to not conflict with the worksheet macro's?

NOTE: removing the 1st item allows the rest to work again. thanks






Per Jessen

MACRO FUNCTION conflict with other macro's
 
Hi

Try to step through the code and see if the UDF is called (recalculated due
to a change in one of the variables).

Hopes this helps.
....
Per

"MrDave" skrev i meddelelsen
...
hi, don't know much about macro's, but the following (with slight
modification), seemed to work. the problem is that while this is
installed,
example of next item below stops in the middle..

- to find if text exists in a formula: installed in a separate module

Option Explicit
Function FC(rng As Range, myStr As String) As Boolean
Set rng = rng.Cells(1)
FC = False
If rng.HasFormula Then
FC = CBool(InStr(1, rng.Formula, myStr, vbTextCompare) 0)
End If
End Function 'for: =FC(a1,"abc")


~~~~~~~~

example of what stops working:

If Range(testB1).Value = "AA" Then
Rows(hidaa).Select
Selection.EntireRow.Hidden = True
Range(hidrows).Select 'this portion does not execute from here
down
Selection.ClearContents
Range(testB1).Select
Selection.ClearContents
End If


If have even the idea right, can I get this modified to insert a function
within a sub / under an option explicit, or does the top item need to be
modified to not conflict with the worksheet macro's?

NOTE: removing the 1st item allows the rest to work again. thanks







MrDave

MACRO FUNCTION conflict with other macro's
 
hi, not sure how to do that, checked all buttons for a step thru.. nada

"Per Jessen" wrote:

Hi

Try to step through the code and see if the UDF is called (recalculated due
to a change in one of the variables).

Hopes this helps.
....
Per

"MrDave" skrev i meddelelsen
...
hi, don't know much about macro's, but the following (with slight
modification), seemed to work. the problem is that while this is
installed,
example of next item below stops in the middle..

- to find if text exists in a formula: installed in a separate module

Option Explicit
Function FC(rng As Range, myStr As String) As Boolean
Set rng = rng.Cells(1)
FC = False
If rng.HasFormula Then
FC = CBool(InStr(1, rng.Formula, myStr, vbTextCompare) 0)
End If
End Function 'for: =FC(a1,"abc")


~~~~~~~~

example of what stops working:

If Range(testB1).Value = "AA" Then
Rows(hidaa).Select
Selection.EntireRow.Hidden = True
Range(hidrows).Select 'this portion does not execute from here
down
Selection.ClearContents
Range(testB1).Select
Selection.ClearContents
End If


If have even the idea right, can I get this modified to insert a function
within a sub / under an option explicit, or does the top item need to be
modified to not conflict with the worksheet macro's?

NOTE: removing the 1st item allows the rest to work again. thanks








Per Jessen

MACRO FUNCTION conflict with other macro's
 
In the VBA editor, hit F8 to step through the selected macro.

....
Per

"MrDave" skrev i meddelelsen
...
hi, not sure how to do that, checked all buttons for a step thru.. nada

"Per Jessen" wrote:

Hi

Try to step through the code and see if the UDF is called (recalculated
due
to a change in one of the variables).

Hopes this helps.
....
Per

"MrDave" skrev i meddelelsen
...
hi, don't know much about macro's, but the following (with slight
modification), seemed to work. the problem is that while this is
installed,
example of next item below stops in the middle..

- to find if text exists in a formula: installed in a separate module

Option Explicit
Function FC(rng As Range, myStr As String) As Boolean
Set rng = rng.Cells(1)
FC = False
If rng.HasFormula Then
FC = CBool(InStr(1, rng.Formula, myStr, vbTextCompare) 0)
End If
End Function 'for: =FC(a1,"abc")


~~~~~~~~

example of what stops working:

If Range(testB1).Value = "AA" Then
Rows(hidaa).Select
Selection.EntireRow.Hidden = True
Range(hidrows).Select 'this portion does not execute from here
down
Selection.ClearContents
Range(testB1).Select
Selection.ClearContents
End If


If have even the idea right, can I get this modified to insert a
function
within a sub / under an option explicit, or does the top item need to
be
modified to not conflict with the worksheet macro's?

NOTE: removing the 1st item allows the rest to work again. thanks










All times are GMT +1. The time now is 09:06 AM.

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