+ Reply to Thread
Results 1 to 5 of 5

Code to Select a "floating" range

  1. #1
    Registered User
    Join Date
    02-24-2009
    Location
    Shelley, ID
    MS-Off Ver
    Excel 2007
    Posts
    10

    Code to Select a "floating" range

    I am pulling in some data from the web...since the data that is pulled in can move around on me, I am using code to find a specific word and then using an offset to select and activate the first cell in a range of 10 cells I want to copy...

    ...now is there a code that would select the current active cell plus the 9 cells below it?? Maybe using R1C1 to have it step down 9 cells selecting all ten cells???

    Of course, this would be really simple if I could count on those ten cells being in the exact same range everyime, but they aren't.

    Here is my code so far:

    Please Login or Register  to view this content.
    ...Now how do I also tell it to highlight and select the 9 cells under the current active cell so I can copy and move the data in all ten cells?

    A code snip it or any help would be greatly appreciated!

    Thanks

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Code to Select a "floating" range

    You could do it like this, which includes a check that the value is found:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-24-2009
    Location
    Shelley, ID
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Code to Select a "floating" range

    Thanks--It worked perfectly!! That will really help me out. I know a little coding, but not a lot, and I often get stuck. Thanks again for the help.


    Trey

  4. #4
    Forum Contributor
    Join Date
    01-28-2008
    MS-Off Ver
    Excel 365
    Posts
    156

    Re: Code to Select a "floating" range

    This seems simpler:
    Sub Test()

    Set Rng = Sheets("DataTemp").UsedRange.Find(What:="Related Companies", After:=ActiveCell, LookIn:= _
    xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
    xlNext, MatchCase:=False, SearchFormat:=False)
    If Not Rng Is Nothing Then
    Range(Rng, Rng.Offset(9, 0)).Activate
    End If
    End Sub

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Code to Select a "floating" range

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

+ 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