+ Reply to Thread
Results 1 to 7 of 7

How to locate the cell y position according to the name of the first row instead of "A-Z"?

  1. #1
    Forum Contributor
    Join Date
    08-01-2016
    Location
    China, beijing
    MS-Off Ver
    2016
    Posts
    114

    How to locate the cell y position according to the name of the first row instead of "A-Z"?

    I want to locate a cell. We can use cells(1, "i"). "I" column means the "type" which is the head(first cell content) of the column. Is there a way to use the name "type" instead of "I"? For the reason that the column of I may change, For example after some modification the I column may change to save the name of the company not type.I want the vba script to be more flexible. Can it be made?

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: How to locate the cell y position according to the name of the first row instead of "A

    Hi,

    This is really a question that belongs in the VBA forum as it is not a simple Excel function like Sum() or Count() or VLookup().

    When you ask a question that is about VBA you need to ask the question from the VBA Forum.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,460

    Re: How to locate the cell y position according to the name of the first row instead of "A

    I have moved the thread to the correct section. Please ensure that threads are started in the appropriate sub-forum in future. Thanks!
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: How to locate the cell y position according to the name of the first row instead of "A

    Try something like this...

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  5. #5
    Valued Forum Contributor
    Join Date
    06-21-2013
    Location
    Bangladesh
    MS-Off Ver
    Excel 2000, Excel XP, Excel 2002, Excel 2007, Excel 2010, Excel 2013
    Posts
    975

    Re: How to locate the cell y position according to the name of the first row instead of "A

    Say column heading in row 1 then you can use :
    Please Login or Register  to view this content.
    Last edited by sanram; 04-18-2017 at 02:34 AM. Reason: Code corrected

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: How to locate the cell y position according to the name of the first row instead of "A

    @ sanram

    I'd use Application instead of Worksheetfunction beause WorkSheetfunction wil go into Debug when no match is found. Application 'stores' the error and can be picked up by using IsError-function.

    Also shouldn't it be Rows(1) ?
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  7. #7
    Valued Forum Contributor
    Join Date
    06-21-2013
    Location
    Bangladesh
    MS-Off Ver
    Excel 2000, Excel XP, Excel 2002, Excel 2007, Excel 2010, Excel 2013
    Posts
    975

    Re: How to locate the cell y position according to the name of the first row instead of "A

    Quote Originally Posted by bakerman2 View Post
    Also shouldn't it be Rows(1) ?
    Yes. It was a typo. I have corrected this already. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 6
    Last Post: 04-12-2016, 05:46 AM
  2. [SOLVED] Formula to Locate Matching Data in Worksheets and return "1" or "0" to a specified Cell
    By hammer2 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-30-2015, 04:52 AM
  3. [SOLVED] Formula to Locate Matching Data in Worksheets and return Yes or "" to a specified Cell
    By hammer2 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-23-2015, 06:12 AM
  4. VBA: How to locate the last "CELL" of a specific "COLUMN"
    By RonGreen in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-16-2013, 04:54 PM
  5. [SOLVED] search for a "part number" within a string and return its cell position or contents of cel
    By benakil in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-24-2013, 06:37 AM
  6. format cell : "Z#.####" minus position issue.
    By jazzaman in forum Excel General
    Replies: 2
    Last Post: 05-27-2011, 03:59 AM
  7. Using the "find" method to locate a cell with a particular value
    By Excel_vba in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-17-2009, 06:16 PM

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