Clearing table without destroying formulas

nmgmarques

Board Regular
Joined
Mar 1, 2011
Messages
133
Office Version
  1. 365
Platform
  1. Windows
Hi all.

Trying to clear Table1 in Worksheet "Análise" without destroying my formulas or existing data validation. This is the original look.
GFiQxnV.png

So far I have tried:
Code:
Sub ClearTables()
    With Worksheets("Análise").ListObjects("Table1")
        If Not .DataBodyRange Is Nothing Then
[B]            .DataBodyRange.SpecialCells(xlCellTypeConstants).ClearContents[/B]
        End If
    End With
End Sub
This clears only cells without formulas and doesn't destroy data validation, but doesn't delete rows nor blank out the cells with formulas.
Q3YavGB.png


Also tried:
Code:
.DataBodyRange.ClearContents
This cleared the entire table, left the data validation, but destroyed the formulas and didn't delete empty rows.
VorWl0n.png


And of course:
Code:
.DataBodyRange.Delete
This one is the closes I got. Deleted all rows except first, leaving it empty. Didn't remove data validation, but did destroy the formulas.
J2cMLPv.png


Can anyone suggest a way to clear, delete empty rows, but keep formulas and validation in first row?
 
Last edited:
You're Welcome.

I can't see anything in your code that would change it.

This setting is Application wide so do you have any other workbooks open?

No other files were open as you can see in the video. I couldn't get it to work but soon realized this was happening in all my files that had macros in them. After stressing out... I finally logged off the server session and kicked myself off to make sure I logged back into a new server. Now all is working perfectly. Probably some CPU brain freeze or whatever.

I'd like to thank everyone for taking the time to help me with this. You guys are great!
 
Upvote 0

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,224,222
Messages
6,177,224
Members
452,765
Latest member
Erka Gizli

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