+ Reply to Thread
Results 1 to 4 of 4

Range selection help!

Hybrid View

  1. #1
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Range selection help!

    I am using the following code to select all of the cells and then fix the font, etc.

    Problem is there is sometimes non-continguous data past what it is selected as the last column....

    Sample i am working on selects all of the data from A1 to U35.... but there is data in v1:y4 that is not being captured.

    how do i get it to grab the data that is in v1:y4 also? If it helps, i do have column Y defined elsewhere as long

    Range("A1", Range("A1").End(xlDown).End(xlToRight)).Select
    Cells.Select does work, but it then grabs ALL of the cells on the sheet, rather than a1:y35 (the row counts and column counts do change based on the sheet... but the last column is always called "apptcol"

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

    Re: Range selection help!

    Try this:
    Dim LastRow as Double
    Dim LastCol as Double
    
    LastRow = Cells(Rows.Count,"A").End(xlUp).Row
    LastCol = Cells(1,Columns.Count).End(xlToLeft).Column
    
    Range(Cells(1,"A"),Cells(LastRow,LastCol)).Select
    If you want to look cool this one line does the above also, if you have no blank rows or columns in your range of data.
    Cells(1,"A").CurrentRegion.Select
    Here is a way to test what excel thinks the CurrentRegion is. Click on a cell and press Ctrl+A. This shortcut will select the CurrentRegion from that cell.
    Last edited by MarvinP; 03-12-2020 at 08:10 PM.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Re: Range selection help!

    Thank you so much!!!!

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

    Re: Range selection help!

    I added to my answer so you might want to reread it again.

+ 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. [SOLVED] Error 1004 Method range of object when trying to clear range selection
    By shoulddt in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-15-2017, 10:09 PM
  2. Copy specific range selection to msword but why it copies columns not in range?
    By adbasanta in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-11-2016, 03:46 AM
  3. Replies: 0
    Last Post: 12-10-2014, 11:30 AM
  4. [SOLVED] I need help range selection and cells selection
    By venkatpvc in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-23-2013, 07:36 PM
  5. [SOLVED] Range(Selection, Selection.End(xlDown)).Select goes to 65536 instead of last filled row
    By looney in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-12-2013, 10:51 AM
  6. Replies: 2
    Last Post: 04-20-2012, 12:23 PM
  7. Hide rows in range 2 based on filter selection in range 1
    By gtol in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 02-28-2012, 02:09 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