Makes table then quits

Dr. Demento

Well-known Member
Joined
Nov 2, 2010
Messages
618
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
One of my subs keeps removing a table, so I'm attempting to force table formatting on data. Using code straight from the recorder, it works on a completely blank page but when I attempt to create a table with data already on a page, it creates the table but then stops. The data has some conditional formatting and a Worksheet_SelectionChange sub to highlight the current row/column.

Any thoughts what's going on and how I can work thru this?

Thanks y'all.

VBA Code:
Sub Macro5()
'
' Macro5 Macro
'

'
    ActiveSheet.ListObjects.add(xlSrcRange, Range("$A$1:$AH$93"), , xlYes).name = _
        "Table89"
    Range("Table89[#All]").Select
    ActiveSheet.ListObjects("Table89").TableStyle = ""
    ActiveSheet.ListObjects("Table89").name = "tbl_Updates"
End Sub
 
What happens if you comment out the entire selectionchange event?
 
Upvote 0

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Ok; I fixed my code so that:
VBA Code:
?Application.EnableEvents = False
but the Sub still quits once the table is created/added.
 
Upvote 0
Yes; even after commenting out the code for the worksheet Selection Change Event, the sub still quits after creating the new table.
 
Upvote 0
In that case it might be down to the conditional formatting.
You could try removing all the CF & see what happens.
 
Upvote 0
If that's the case, then I probably would be best served by copying the data from the offending page on to a new sheet, apply the required table, and then copy the entire thing back on to the original sheet. Unless, you can think of a different option . . . I think I'm out of options (I need the CF). Ah well *sigh*

Thanks for your help, Fluff.
 
Upvote 0
Make a copy of your workbook & delete the Cf in that copy & see if it makes a difference.
 
Upvote 0

Forum statistics

Threads
1,214,889
Messages
6,122,097
Members
449,065
Latest member
albertocarrillom

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