This site has a good description of the problem:Īn error handling block, also called an error handler, is a section of code to which execution is tranferred via a On Error Goto : statement. This clearly delineates error handling from regular code and ensures that the currently executing error handler finishes before you try to set up another handler. That means that subsequent error handlers are not allowed until you resume from the current one.Ī better architecture would be: Dim m圜ol As ListColumn With the code as shown, you're actually still considered to be within the error handling routine when you strike the next statement. To reiterate, the error is thrown on the second round of the loop, at the statement myDate = CDate(m圜ol.Name)Ĭan anyone explain why the On Error statement stops working? However, when the second column's header is 'assigned' to the date-type variable, the macro encounters an error even though it is within an error-handling block Dim m圜ol As ListColumn Since the first three columns do not have date headers, I have tried to set the loop up so that, if there is an error assigning the header string to the date-type variable, the loop goes straight to the next column To do this I am using a foreach loop on myTable.ListColumns. I want to assign those dates, sequentially, to a Date-type variable, and then perform some operations based on the date The first three columns of this table have text headings, the rest of them have dates as headings. I'm trying to cycle through a table in excel.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2023
Categories |