Clearing DataTable But Retain Formulas

03856me

Active Member
Joined
Apr 4, 2008
Messages
297
I have a dataTable in Excel 2007 that contains columns A-P that are entered via a UserForm which works perfectly. There are formulas in columns Q through KO (285 columns, wow). So far so good.

Steps my user goes through:
Step 1) Enter the data via UserForm starting on row 2 of the dataTable
Step 2) Generate Reports, Graphs, Etc. for this project
Step 3) Saves the data only (columns A-P) to an external file (which can be imported later if need be)
Step 4) Clears dataTable to start new project

Steps 1 through 3 are working fine, it is step 4 that is causing the problem. When I clear the data in the table I leave row 1 intact so it keeps the formulas in columns Q-KO. This works if I do it manually but when I do it with this macro, the next time they add data the formulas don't continue down. I am beginning in the 2nd row of the dataTable, could that be the problem? Also, I am using EntireRow.Delete for rows 2 to the end because there could be 500 or so rows of data.

Your help is greatly appreciated.

Code:
Sub ResetData()
    Application.ScreenUpdating = False
    ActiveSheet.DisplayPageBreaks = False
 
    Sheets("Main Menu").Select
    Sheets("data").Visible = True
    Sheets("DATA").Select
    ActiveSheet.Cells.EntireColumn.Hidden = False
    ActiveSheet.Cells.EntireRow.Hidden = False
    Range("A7").Select
 
    Range("dataTable[[plot]:[vc3]]").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.EntireRow.Delete  'ClearContents
 
'I tried this but then the formulas are gone completely 
'    Range("dataTable").Offset(1).SpecialCells(xlCellTypeConstants).ClearContents
 
    Range("dataTable[[L1length]:[Form Class]]").Select
    Selection.EntireColumn.Hidden = True
    Range("A6").Select
    Sheets("data").Visible = False
 
    Application.ScreenUpdating = True
End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,214,641
Messages
6,120,684
Members
448,977
Latest member
dbonilla0331

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