Clear and Resize Table But keep formulas

03856me

Active Member
Joined
Apr 4, 2008
Messages
297
Excel 2007
I have a dataTable where data is entered via a UserForm in columns A-P, starting on row 6 (headers are on row 5). Columns Q-KN contain all formulas are are hidden during input.

Here is the code I have come up with to clear the data, which works ok, except it leave all the rows that do not contain data in rows 6 through ??. The formulas must be kept so when new data is added all goes well. Should I leave one blank row on 6?

Any suggestions on how to protect the formulas and get rid of empty rows?


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("A6").Select
 
    Range("dataTable[[plot]:[vc3]]").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.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

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,215,443
Messages
6,124,887
Members
449,193
Latest member
ronnyf85

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