ClearContents not clearing :(

  • Thread starter Thread starter JoeH
  • Start date Start date
J

JoeH

Hi,

I am using the following to clear a range of cells but it dosen't
work please help

With
Workbooks("testcalcs_rev3.xls").Worksheets("initial_information")
trm =
Workbooks("TestCalcs_rev3.xls").Names("Issue_term").RefersToRange.Value
If trm = 20 Then
Columns("C:L").Rows("70:89").ClearContents
End If
End With

I can run the clearcontents by itself and it works fine but i need to
be able to compare it to a value, hence the cell issue_term. if it
equals 20 then i need to delete the cells listed if not it needs to
just exit.

thanks for your time
joeH
 
Dim trm as Long

With Workbooks("testcalcs_rev3.xls"). _
Worksheets("initial_information")
trm = Workbooks("TestCalcs_rev3.xls").Names( _
"Issue_term").RefersToRange.Value
msgbox trm
If trm = 20 Then
.Columns("C:L").Rows("70:89").ClearContents
End If
End With

Usually if something is within an IF construct and it doesn't occur, then
the if construct test is not being passed. Use the msgbox to check the
value of trm
 

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

Back
Top