+ Reply to Thread
Results 1 to 9 of 9

Excel VBA: Select 50th Row from the top of the sheet

  1. #1
    Forum Contributor
    Join Date
    02-19-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    110

    Excel VBA: Select 50th Row from the top of the sheet

    Hello,

    I'm looking for a code to say:

    - Select 50th cell from the top of the sheet, basing it from the ActiveCell


    Example
    Active Cell is: C79
    Select: C50
    Last edited by clprdctn; 08-08-2016 at 11:44 AM.

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

    Re: Excel VBA: Select 50th Row from the top of the sheet

    Cells(50, ActiveCell.Column).Select
    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.

  3. #3
    Forum Contributor
    Join Date
    02-19-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: Excel VBA: Select 50th Row from the top of the sheet

    Thank you Alpha - How can I make it applicable to a merged cell? I didn't realize that was going to be an issue.

    In the example above, the "title" i'm trying to select can be on B50 or A50. Is there any way?

    Active Cell is: C79
    Select: C50

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Excel VBA: Select 50th Row from the top of the sheet

    ...just a comment on good practice.

    Try to avoid selecting or activating stuff. Rarely is this necessary although I accept this may be an exception if you do want to position the cursor on C50 and look at it rather than do something with it.

    Just refer directly to the object in question. Selecting stuff has a time overhead and with larger systems and macros can really slow things down considerably.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

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

    Re: Excel VBA: Select 50th Row from the top of the sheet

    Quote Originally Posted by clprdctn View Post
    Thank you Alpha - How can I make it applicable to a merged cell? I didn't realize that was going to be an issue.

    In the example above, the "title" i'm trying to select can be on B50 or A50. Is there any way?

    Active Cell is: C79
    Select: C50
    I know what a merged cell is. I don't follow what you're asking.

    If C79 is the active cell, it will select C50. If C50 is part of merged cells, it will select the entire merged cells.

  6. #6
    Forum Contributor
    Join Date
    02-19-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: Excel VBA: Select 50th Row from the top of the sheet

    Maybe I'm plugging it wrong then - because I'm doing exactly that:

    If C79 is the active cell, it selects C50. C50 is part of merged cells, however it does not select the entire merged cell.


    If it helps here's the full wording in that row of that VBA:


    Please Login or Register  to view this content.

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Excel VBA: Select 50th Row from the top of the sheet

    ...This is somewhat confusing. Your original question concerned navigating to a particular cell. You now seem to be flagging up something else to do with Outlook.

    Apart from selecting C50 (presumably with some other macro since there's no selecting taking place in this latest code) )which is merged and hence the whole of the merged range is outlined although C50 is regarded as the 'Active' cell, what are you attempting to do?

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

    Re: Excel VBA: Select 50th Row from the top of the sheet

    Your example code doesn't "Select" any cell. If you want to get the value of the merged cells, try something like this...
    Cells(50, ActiveCell.Column).MergeArea(1).Value

  9. #9
    Forum Contributor
    Join Date
    02-19-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: Excel VBA: Select 50th Row from the top of the sheet

    It works - thank you AlphaFrog!

+ 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. select A1 on each sheet and activate sheet 1 when opening excel file
    By k_amy21 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-17-2015, 09:13 AM
  2. Working piece of code to calculate 50th percentile in a pivot plot .
    By acoron01 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-06-2013, 12:56 PM
  3. Code to select, and then open CSV file into an Excel sheet
    By Rschwar2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-24-2012, 05:55 PM
  4. Importing Select Data from One Excel Sheet to Another
    By abgemacht in forum Excel General
    Replies: 0
    Last Post: 07-16-2008, 08:55 AM
  5. Copying Select Data From one EXCEL Sheet to Another
    By kishor.gala in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-22-2007, 09:12 PM
  6. [SOLVED] Select and Delete Every Other Row in Excel Sheet
    By Sawyer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-17-2006, 03:20 PM
  7. Select and Insert one sheet from a multisheet excel template
    By Alex at Europlan in forum Excel General
    Replies: 0
    Last Post: 11-22-2005, 11:55 AM

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