+ Reply to Thread
Results 1 to 9 of 9

selecting range A1:B2

  1. #1
    Forum Contributor
    Join Date
    08-14-2013
    Location
    LA Baby!!
    MS-Off Ver
    Excel 2007
    Posts
    1,598

    selecting range A1:B2

    Hello. I have data with A1:B2 and that's it. Why isn't this code capturing that?

    Please Login or Register  to view this content.
    Thanks.

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: selecting range A1:B2

    Are you trying to select, copy or both, A1 and B2? Your code is set to select/copy A1 and B1.
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  3. #3
    Forum Contributor
    Join Date
    08-14-2013
    Location
    LA Baby!!
    MS-Off Ver
    Excel 2007
    Posts
    1,598

    Re: selecting range A1:B2

    What do you mean? It's supposed to capture the last row in B, which is B2, so the range should be A1 to B2. Below is complete code.


    Please Login or Register  to view this content.

  4. #4
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: selecting range A1:B2

    You are right, I didn't have anything in cell B2 so it didn't select it, once I did put a value in B2, the copy part of the code worked. However, I couldn't get the Paste part of the code to work until I changed Sheets(s + 1) to Sheets("Sheet2"). I'm guessing I'm missing something with the s + 1 part.

  5. #5
    Forum Contributor
    Join Date
    08-14-2013
    Location
    LA Baby!!
    MS-Off Ver
    Excel 2007
    Posts
    1,598

    Re: selecting range A1:B2

    I changed it to sheet2 as well and it still doesn't work. It just copies the first row from income statement twice. The s+1 just creates a new sheet.

  6. #6
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: selecting range A1:B2

    When using the Cells property you need to also reference the sheet. A lack of a reference indicates the Activesheet which may or may not be correct.

    Please Login or Register  to view this content.
    Note: The s+1 does not create a new sheet unless you are acutally creating a new sheet in code we cannot see.
    If you are happy with my response please click the * in the lower left of my post.

  7. #7
    Forum Contributor
    Join Date
    08-14-2013
    Location
    LA Baby!!
    MS-Off Ver
    Excel 2007
    Posts
    1,598

    Re: selecting range A1:B2

    I tried using this and I also got an error. @ stinky, I'll try your code in a second.

  8. #8
    Forum Contributor
    Join Date
    08-14-2013
    Location
    LA Baby!!
    MS-Off Ver
    Excel 2007
    Posts
    1,598

    Re: selecting range A1:B2

    @ stinky, your code works. How could I do it with two ranges instead of that last cell piece?

  9. #9
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: selecting range A1:B2

    How could I do it with two ranges instead of that last cell piece?
    I am not sure I understand what you mean. Do you mean like this?

    Please Login or Register  to view this content.

+ 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 Range for Autofill: Select Last range.
    By enyak in forum Excel General
    Replies: 1
    Last Post: 06-19-2014, 11:43 PM
  2. [SOLVED] Selecting a range of consecutive cells within a range
    By 8-bit in forum Excel General
    Replies: 2
    Last Post: 04-22-2012, 06:35 PM
  3. Error When Selecting Sheet then Selecting Range
    By jordan2322 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-08-2012, 04:11 AM
  4. Selecting range using .range. But can you do same selection using .columns
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-01-2011, 01:31 PM
  5. Copy/Paste Range(s) without activating/selecting Range(s)
    By hmissoumi in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-03-2008, 01:29 PM
  6. Replies: 2
    Last Post: 06-19-2006, 06:10 AM
  7. [SOLVED] selecting date range / data range autofilter
    By hansiman in forum Excel General
    Replies: 1
    Last Post: 02-23-2005, 09:06 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