Select individual cells only?

  • Thread starter Thread starter Sige
  • Start date Start date
S

Sige

Goodmorning All,

Is it possible allowing a user to select individual cells only?
No ranges with cells.count>1?

Brgds Sige
 
Hi Sige

You can test the area

Sub zzzz()
Dim smallrng As Range
For Each smallrng In Selection.Areas
If smallrng.Cells.Count > 1 Then MsgBox smallrng.Address & " is not a correct selection"
Next
End Sub
 
see if this is what you're looking for. right click a sheet tab, select view
code and paste it there.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count > 1 Then
MsgBox Target.Address & " is not a correct selection"
End If
End Sub
 
modified it a bit to not allow action on the range after the msgbox was
displayed

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count > 1 Then
MsgBox Target.Address & " is not a correct selection"
ActiveCell.CurrentRegion.Cells(1, 1).Select
End If
End Sub
 
Hi Gary,
Is what I am looking for!
Though ..I would like to invoke this on workbooks which I download
every day with around 70 sheets ...

Any ideas?
Sige
 
Hi Ron,
Works fine ... but as worksheet_selectchange it does what I am after.
Or quite. As I would like to have this message on every sheet in my
workbook!
But every day I start with a fresh one with about 70 sheets!

Any ideas?

MVG Sige
 
Hi Ron,

It does what it should ...but as Worksheet_SelectionChange-sub it has
the behaviour which I had in mind... or quite. As I would like to
invoke this behaviour on a fresh workbook with 70 sheets.
No other way than copying it in 1by1?

MVG Sige
 
Hi Sige,

Use the Workbookbook_SheetSelectionChange event instead. This event will
operate on all sheets, existing and new.
 

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

Similar Threads


Back
Top