• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macros work on Windows, fail on Macs

LisaF

New Member
I call two small subroutines as part of a larger macro. They work perfectly in Windows (tested in Excel 2010 and 2013) but cause error messages on Macs (in Office 2011). I have very limited access to Macs - I had to use a computer in another department to debug the code - so I would appreciate any insight into the causes of the problems and how to fix them.

The first macro is meant to convert any existing table to a range, the second formats a range as a table with a specified name.

Code:
Sub UnlistListObjects()
  Do While ActiveSheet.ListObjects.Count > 0
  ActiveSheet.ListObjects(1).unlist
  Loop
End Sub

Sub formatAsTable_Vacancies()
  Dim tbl As ListObject
  Dim rng As Range
  Set rng = Range(Range("A2"), Range("a65536").End(xlUp).Offset(0, 11))
  Set tbl = ActiveSheet.ListObjects.Add(xlSrcRange, rng, , xlYes)
  tbl.TableStyle = "TableStyleLight9"
  tbl.Name = "VacanciesTable"
End Sub

Any help will be greatly appreciated!

Cheers,
Lisa
 
Narayan,

Thank you for your reply. Unfortunately, when I tried to implement the code, it failed on Windows. Is there code that will work on both Windows and Macs, or do I have to write separate macros for each platform?

Cheers,
Lisa
 
Never mind, I just went ahead and wrote separate macros for each. Thanks for pointing me in the right direction!
 
Back
Top