Selecting Data on a Spreadsheet

  • Thread starter Thread starter BenTarnowski
  • Start date Start date
B

BenTarnowski

I want to click on a cell in an Excel spreadsheet and then press a
control button that will perform an operation on that selected cell.
E.g. if my cursor is highlighting cell A4, I can press a button that
will do something with the data in A4. Is this a Worksheet_Change
function, or does someone have an easy solution for this? Thanks.

Ben
 
Make a button using the Forms Toolbar and then assign it to a macro like:

Sub bentar()
MsgBox (Selection.Address & Chr(10) & Selection.Value)
End Sub
 
Make a button using the Forms Toolbar and then assign it to a macro like:

Sub bentar()
MsgBox (Selection.Address & Chr(10) & Selection.Value)
End Sub

--
Gary''s Student - gsnu2007






- Show quoted text -

Well, I actually figured it out and was using:

ActiveCell.Value

But I want to do a range check with the ActiveCell function, but it
isn't really working. I want to define a range on the worksheets. If
the active cell is not within that range, I'll display a MsgBox. I
thought this might work.

Public Sub Check()

Dim Range1 As Range: Dim Range2 As Range
Range1 = Worksheets("Sheet1").Range(ActiveCell, ActiveCell)
Range2 = Worksheets("Sheet1").Range("A1:M30")
If Not Application.Intersect(Range1, Range2) Then
MsgBox(...)
End If

End Sub

I don't get past the second line without getting a "Run-time error
'9': Subscript out of range" error. Any ideas?

Ben
 
Back
Top