+ Reply to Thread
Results 1 to 8 of 8

Problem Selecting a Range of Cells with Unknown Row Length - Macro

  1. #1
    Registered User
    Join Date
    07-08-2013
    Location
    Fort Wayne, IN
    MS-Off Ver
    Excel 2010
    Posts
    61

    Problem Selecting a Range of Cells with Unknown Row Length - Macro

    Hello all,
    I am currently trying to copy and paste a large range of cells that always has the same amount of columns but can have a different number of rows based on user input.

    I am working with the following code but can't quite figure out the syntax to make it work.

    Please Login or Register  to view this content.
    Any suggestions on how to select or copy that range?

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Problem Selecting a Range of Cells with Unknown Row Length - Macro

    Hi, ahilty,

    maybe like this
    Please Login or Register  to view this content.
    Why do you check in Column M for teh last row when data is copied until Column Q?

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Problem Selecting a Range of Cells with Unknown Row Length - Macro

    You can change the column range.

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Problem Selecting a Range of Cells with Unknown Row Length - Macro

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-08-2013
    Location
    Fort Wayne, IN
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Problem Selecting a Range of Cells with Unknown Row Length - Macro

    HaHoBe,

    Thank you very much - that worked wonders.
    The reason the column M is used is because there are some cases that the data in column M has more values at the end then any other column. If I had chose Column Q, there would be a chance that some values would be missing.

    AB33,
    I'm sure that would also work, but because I already entered HaHoBe's idea with success, I will not be trying it.

    Thank you both for the suggestions - reputation added.

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Problem Selecting a Range of Cells with Unknown Row Length - Macro

    They are the same code. No need to activate.

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Problem Selecting a Range of Cells with Unknown Row Length - Macro

    Hi, AB33,

    They are the same code. No need to activate.
    You´re as right about not activating as wrong about code being the same: Column 17 is and will ever be Q, not Z - no matter how many posts you will fill in.

    Holger

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Problem Selecting a Range of Cells with Unknown Row Length - Macro

    Holger,
    Please Login or Register  to view this content.
    You can change the column range

+ 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