Solved

Active RowFunction in Excel 2007

Posted on 2012-03-12
3
298 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
3 Comments
 
LVL 50

Accepted Solution

by:
Ingeborg Hawighorst 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

We were having a lot of "Heartbeat Alerts" in our SCOM environment, now "Heartbeat" in a SCOM environment for those of you who might not be familiar with SCOM is a packet of data sent from the agent to the management server on a regular basis, basic…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now