[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Active RowFunction in Excel 2007

Posted on 2012-03-12
3
Medium Priority
?
336 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 1000 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 1000 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
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.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

656 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