excel command to clear contents except 2 formulas

G

Guest

I have an excel database that when being accessed each time l need to clear
the contents of the previous record. I have created a macro through VBA to
clear my drop down and option boxes. Does anyone know of the command that
will clear my text fields of information. The gotcha here is l have a
formula in cells c7 and c22 that l don't want whipped out. One is an age
calculator formula and the other one is a hours/minute formula calculation.
I know l can type the range with clear contents in the command. I am unsure
how you eliminate c7, c22 from that command.

Any help would be greatly appreciated

Lynda S
 
N

Nick Hodge

Lynda

Something like

Sub ClearAllButFormulae()
Range("A1:H23").SpecialCells(xlCellTypeConstants).Clear
End Sub

Will remove constants from A1:H23

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk
(e-mail address removed)
 
G

Gord Dibben

Lynda

Sub clearout()
Set rng1 = Selection.SpecialCells(xlCellTypeConstants, _
xlTextValues)
rng1.ClearContents
End Sub


Gord Dibben MS Excel MVP
 
G

Guest

Thank you for your reply. I didn't think about that scenario. I just need
to think how l will type in the groupings

Lynda
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top