Solved

Active RowFunction in Excel 2007

Posted on 2012-03-12
3
323 Views
Last Modified: 2012-03-12
I'm tyring to create a function that would always display the row of the active cell in the cell you place the funtion in. In other words, if I placed '=ShowRow()' in Cell A3, then the value in Cell A3 should always be the row of the active cell; everytime you click on a different cell, the value in Cell A3 should automatically update to indicate the row of the active cell.

I tried this code in VBA:

Function ShowRow()
ShowRow = ActiveCell.Row
End Function

Which works ok the first time you type it, but it doesn't update as you select different cells in the spreadsheet. Seems like there should be a standard Excel function to do this, but apparently not.
0
Comment
Question by:restabro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 50

Accepted Solution

by:
Ingeborg Hawighorst (Microsoft MVP / EE MVE) earned 250 total points
ID: 37711855
Hello,

this code will show the row of the current cell in A1

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

This code needs to go into the Sheet module (right-click the sheet tab  > View Code > Paste the code into the code window).

cheers, teylyn
0
 
LVL 43

Assisted Solution

by:Saqib Husain, Syed
Saqib Husain, Syed earned 250 total points
ID: 37711864
Right-click on the sheet tab name
Select view code
Paste this code there

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("A1").Value = ActiveCell.Row
End Sub
0
 

Author Closing Comment

by:restabro
ID: 37711977
Both responses worked and I really appreciate the detailed instructions on how to apply it! Thank you!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question