Clear contents in table but leave columns with formulas

thedeadzeds

Active Member
Joined
Aug 16, 2011
Messages
451
Office Version
  1. 365
Platform
  1. Windows
Hi Guys,

I have 2 tables one named 'Steve' and the Other named 'Dave'.

Is there a way to use VBA to clear the contents of both tables but leave the formulas in columns R,S,T,U,V. At the moment i just select all rows from row 3 down (leaving the heading and row 2) and delete . I then paste the new data into A2 as values and the formulas in R,S,T,U,V auto copy down.

Thanks


[TABLE="width: 2614"]
<colgroup><col><col><col><col><col span="3"><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><tbody>[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hey, how about something like this:

Code:
Sub ClearNonFormulaeSteveAndDave()
    Dim cell As Range
    Dim rngSteve As Range
    Dim rngDave As Range
    Set rngSteve = Range("Steve")
    Set rngDave = Range("Dave")
        For Each cell In rngSteve
            If cell.HasFormula = False Then
                cell.ClearContents
            End If
        Next cell
        For Each cell In rngDave
            If cell.HasFormula = False Then
                cell.ClearContents
            End If
        Next cell
End Sub

I'd save your work before testing it but it should delete all non formula cells from the tables "Steve" and "Dave".
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,279
Members
452,630
Latest member
OdubiYouth

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