+ Reply to Thread
Results 1 to 5 of 5

selecting cells one to the right of highlighted row

Hybrid View

  1. #1
    Registered User
    Join Date
    09-04-2014
    Location
    Sydney, Australia
    MS-Off Ver
    2013
    Posts
    52

    Question selecting cells one to the right of highlighted row

    Hi all, I currently have this code to select data in a row. I need the macro to always select the cell one to the right of the highlighted selection (ie. the next blank cell in the row) How would I do this? Appreciate any help ,thanks!

        Range("F21").Select
        Range(Selection, Selection.End(xlToRight)).Select

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: selecting cells one to the right of highlighted row

    May be try something like this...

    Selection.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Offset(, 1).Select


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    09-04-2014
    Location
    Sydney, Australia
    MS-Off Ver
    2013
    Posts
    52

    Re: selecting cells one to the right of highlighted row

    Thank you for your reply Sixthsense I have this error coming up when I try that - 'run-time error '91': Object variable or with block variable not set'

  4. #4
    Registered User
    Join Date
    09-04-2014
    Location
    Sydney, Australia
    MS-Off Ver
    2013
    Posts
    52

    Re: selecting cells one to the right of highlighted row

    It is most likely my fault for changing my method of selection, I now have this code however I still need to make it so that rows 21-23 are selected without the column reference

        Selection.End(xlToRight).Select
         Range("U21:U23").Select
         Selection.Copy
         Windows("data.xlsx").Activate
         Range("I23:I25").Select
         Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
             :=False, Transpose:=False
     End Sub

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,548

    Re: selecting cells one to the right of highlighted row

    "always select the cell one to the right of the highlighted selection"
    ActiveCell.Offset(, 1).Select
    "the next blank cell in the row"
    Cells(ActiveCell.Row, Columns.Count).End(xlToLeft).Offset(, 1).Select
    "rows 21-23 are selected without the column reference"
    Rows("21:23").Select
    This is not what you mean I am sure but it is IMHO what you asked for.

    A detailed explanation is in my opinion better than a code that does not do what you want.

    Note: Selecting is a waste and should not be used if not required.

+ 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. Selecting rows with highlighted cells
    By jsuma in forum Excel General
    Replies: 3
    Last Post: 10-06-2014, 02:34 PM
  2. need a U.D.F to sum up cells highlighted Red
    By James__S in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-16-2014, 04:03 PM
  3. Highlight cells for data entry but print workbook with no highlighted cells
    By kheino1111 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-30-2014, 06:51 AM
  4. Two cells highlighted but want one
    By deb05 in forum Excel - New Users/Basics
    Replies: 7
    Last Post: 09-24-2013, 10:58 AM
  5. Replies: 1
    Last Post: 11-17-2010, 11:53 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