Macro triggering other Subs not working: Weird

SakiSam

New Member
Joined
Jul 25, 2014
Messages
20
I have a Module that has worked for almost a year but is now not working. I've had to rebuild the worksheet because of a un-delete-able style issue that was causing confusion on the part of the end users. So I copied this module into the new workbook.

Here's a sample:
Code:
Sub VehInv()    cntYear = (ThisWorkbook.Sheets(xPage11).Cells(Rows.Count - 1, PivTbl).End(xlUp).Row - 4)
    Sheets(xPage01).Select
'Clear existing Table
    ClearOldData
'The first TagType, alphabetically
    TagTypeB
'Other Tag Types
    TagTypeO
'Format Present
    FormatChart

If Sheets(xPage01).UsedRange.SpecialCells(xlCellTypeLastCell).Offset(-1) = "" Then Sheets(xPage01).Range(Sheets(xPage01).UsedRange.SpecialCells(xlCellTypeLastCell).End(xlUp).Offset(1), Sheets(xPage01).UsedRange.SpecialCells(xlCellTypeLastCell)).EntireRow.Delete shift:=xlUp
End Sub
______________________________________________________________________________________________________

Sub ClearOldData()
    rownum = Sheets(xPage01).Cells(fstRow, fstcol).End(xlDown).Row
    Sheets(xPage01).Range(Sheets(xPage01).Cells(fstRow, fstcol).Address & ":" & Sheets(xPage01).Cells(rownum, lstcol).Address).EntireRow.Delete shift:=xlUp
End Sub
When I trigger "VehInv" the code works as it should and runs the sub "ClearOldData". However after ClearOldData completes, the Macro stops and never returns to VehInv to run the next step.

I've tried checking VBA's Options and Reference(Library's.) Can anyone tell me how to fix this?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Do you have any event code in the xPage01 sheet? Or any conditional formatting that uses UDFs?
 
Upvote 0
I do not have any VBA in the xPage01 sheet. but I do have a conditional formatting that uses a UDF. If it matters, the condition is on a cell that is not included in the "ClearData" and uses a cell that is also not included.

Code:
=ISERROR(COUNTav($H$2))
 
Upvote 0
If you save a copy of the workbook and clear that conditional formatting, does the code then work?
 
Upvote 0
That did it. Any idea why that happened? Is it because the UDF includes "Application.Volatile"?
 
Upvote 0
No (Conditional Formatting is volatile anyway). There are certain properties of ranges that aren't always valid and if your UDF tries to access them from within CF at the wrong time, it simply terminates all code without warning. Most of the time you can work around it with error handling, or an alternative approach.
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,935
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top