Clearing Row Contents (using Intersect?)

  • Thread starter Thread starter deelee
  • Start date Start date
D

deelee

I'm back again!

I would be grateful if I could have some help with the following
problem:

I have a spreadsheet that is 306 lines long by 13 coulmns wide. All
cells are 'unprotected' with the exception of columns 'D', 'K' and 'M'
which get their data via fomula from unlocked cells or each other.

What I would like to do is to have a 'button' which will, when pressed,
clear the row of the active cell 'A' i.e' activate a cell in column 'A'
and pressing the 'Clear' button clears the entire adjacent row. (the
ranges would be(""A:C", "E:J", "L")).

I've played around with intersect but can only get the active cell to
clear!

Incidentally, I've a 'Sort' macro which will subsequently move all
empty rows to the bottom of the sheet.

Thanks in advance,

Dave
 
Hello Dave,

Here's the macro. Copy and paste this into a VBA module. You can then
call it from your buttons Click() event.

Public Sub Clear()
Dim Rng As Range
With ActiveSheet
Set Rng = Application.Intersect(.Range("A:C"), .Range("E:J"),
..Range("L"))
End With
Rng.ClearContents
End Sub

Sincerely,
Leith Ross
 
:( Hi Ross,

Thanks for your quick reply, however, when I use it the routine fails
at the Set Rng statement? I've double checked the ranges and they are
correct.

Thanks again,

Dave
 
Hi Deelee,

Try:

'=============>>
Public Sub Tester()
Dim rng As Range

Set rng = Intersect(Range("A:C,E:J,L:L"), _
ActiveCell.EntireRow)
rng.ClearContents

End Sub
'<<=============
 
;) Hi Norman and thank you!

It worked a treat - another one for my library!

Dave
 

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