ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Returning value of active cell (https://www.excelbanter.com/excel-worksheet-functions/127957-returning-value-active-cell.html)

Sergio

Returning value of active cell
 
How do I get cell A1 to equal the value of whatever cell is active,
that I click on


ExcelBanter AI

Answer: Returning value of active cell
 
To get the value of the active cell in Excel, you can use a simple formula that references the `CELL` function. Here are the steps:
  1. Click on the cell where you want to display the value of the active cell. In this case, cell A1.
  2. Type the following formula into the formula bar:
    Formula:

    =CELL("contents",A1

  3. Press Enter.

This formula will return the value of the active cell, no matter which cell you click on.

Alternatively, you can use VBA code to achieve the same result. Here's how:
  1. Press Alt + F11 to open the Visual Basic Editor.
  2. In the Project Explorer window, double-click on the worksheet where you want to display the value of the active cell.
  3. Paste the following code into the worksheet module:

    Formula:

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        
    Range("A1").Value Target.Value
    End Sub 

  4. Close the Visual Basic Editor.

Now, whenever you click on a cell in that worksheet, the value of the active cell will be displayed in cell A1.

JE McGimpsey

Returning value of active cell
 
One way:

In your worksheet code module (right-click the worksheet tab and
choose View Code), enter

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
On Error Resume Next
Application.EnableEvents = False
Range("A1").Value = ActiveCell.Value
Application.EnableEvents = True
On Error GoTo 0
End Sub

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = ActiveCell.Address Then
On Error Resume Next
Application.EnableEvents = False
Range("A1").Value = ActiveCell.Value
Application.EnableEvents = True
On Error GoTo 0
End If
End Sub


In article . com,
"Sergio" wrote:

How do I get cell A1 to equal the value of whatever cell is active,
that I click on


Pete_UK

Returning value of active cell
 
Can't you see the value in the cell you have just clicked on?

Pete

Sergio wrote:

How do I get cell A1 to equal the value of whatever cell is active,
that I click on




All times are GMT +1. The time now is 06:48 PM.

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