ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Selecting Data on a Spreadsheet (https://www.excelbanter.com/excel-discussion-misc-queries/158328-selecting-data-spreadsheet.html)

[email protected]

Selecting Data on a Spreadsheet
 
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


Gary''s Student

Selecting Data on a Spreadsheet
 
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


" wrote:

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



[email protected]

Selecting Data on a Spreadsheet
 
On Sep 14, 2:38 pm, Gary''s Student
wrote:
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



" wrote:
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- Hide quoted text -


- 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



All times are GMT +1. The time now is 01:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com