+ Reply to Thread
Results 1 to 2 of 2

Coding to Find Cell and Retrieve Row and Column Numbers

  1. #1
    Registered User
    Join Date
    10-05-2012
    Location
    Richmond, Virginia
    MS-Off Ver
    Excel 2010
    Posts
    8

    Coding to Find Cell and Retrieve Row and Column Numbers

    Excel 2010.

    I have code behind an Excel workbook. How would I do the following programmatically in VBA?

    1. Search the active worksheet for a particular text value in a cell?
    2. Once that cell is found, determine the row and column in which it is found.

    I used the macro recorder to do item 1 above, resulting in:

    .Cells.Find(What:="attendance information", After:=ActiveCell, LookIn:= _
    xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
    xlNext, MatchCase:=False, SearchFormat:=False).Activate

    But I do not know how to then determine (and set a variable to) to row and column numbers of the cell in which the string was found.

    Any help will be greatly appreciated. Thank you.

  2. #2
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: Coding to Find Cell and Retrieve Row and Column Numbers

    Hi
    Add the follow code line to the end of your code:

    CellLocation = ActiveCell.Address

    Don't forget to add Dim Cell Location at the beginning of your code.
    Good luck.
    Tony

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1