+ Reply to Thread
Results 1 to 9 of 9

VBA Macro Order and Copy row when input integer

  1. #1
    Registered User
    Join Date
    08-16-2012
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2003
    Posts
    9

    VBA Macro Order and Copy row when input integer

    Hello! I am working through manual data trying to organize a range of information by inputting numbers 1 - n. Example I have an excel sheet populated with x number of cells on both the x and y axis. Column A is blank to allow for me to manually input an integer 1 - n. I want to be able to be able to label random cells in column A 1 - n and then based on the number input I would like that to then be copied in numerical order into another sheet.

    A B C D....
    App AB CD
    1 EF GH IJ
    KL MN OP
    3 QR ST UV
    2 WX YZ AB

    In the example above based on my input of the numbers in column A the VBA should copy the rows with numbers to another sheet and order them in numerical order. Below is what the result should be if the macro worked. Row length should not have a cell range for being copied then number of integers can be capped at 100.
    A B C D....
    1 EF GH IJ
    2 WX YZ AB
    3 QR ST UV

    I need it to copy the source list to another sheet. If I have a set of data that spans through row 100 and I only order 1 - 10 I want those rows I put a 1 - 10 in to copy and paste to a new tab in order 1 - 10.
    Last edited by bjohnsman; 04-14-2017 at 04:00 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA Macro Order and Copy row when input integer

    Hi,

    Assuming your data has column header labels then

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    08-16-2012
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: VBA Macro Order and Copy row when input integer

    Thanks for the quick reply, this is currently just adding filters to my current list and sorting the numbers in order. I need it to copy the source list to another sheet. If I have a set of data that spans through row 100 and I only order 1 - 10 I want those rows I put a 1 - 10 in to copy and paste to a new tab in order 1 - 10.

  4. #4
    Registered User
    Join Date
    08-16-2012
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: VBA Macro Order and Copy row when input integer

    Thanks for the quick reply, this is currently just adding filters to my current list and sorting the numbers in order. I need it to copy the source list to another sheet. If I have a set of data that spans through row 100 and I only order 1 - 10 I want those rows I put a 1 - 10 in to copy and paste to a new tab in order 1 - 10.

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA Macro Order and Copy row when input integer

    Quote Originally Posted by bjohnsman View Post
    Thanks for the quick reply, this is currently just adding filters to my current list and sorting the numbers in order. I need it to copy the source list to another sheet. If I have a set of data that spans through row 100 and I only order 1 - 10 I want those rows I put a 1 - 10 in to copy and paste to a new tab in order 1 - 10.
    Hi,

    On my system it filters the data on sheet1, copies all rows which have numbers in column A to Sheet2 and then sorts Sheet2.
    Without seeing your workbook it's difficult to see why yours doesn't exhibit the same behaviour.

    Please therefore upload your workbook and manually add the results you expect to see. Clearly identify which data is the original data and which is the results.
    Make sure you cover all permutations and combinations of data and include a representative sample of your real data rather than any simplified version,

  6. #6
    Registered User
    Join Date
    08-16-2012
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: VBA Macro Order and Copy row when input integer

    Hi Richard thanks for the reply. It works but if there are column labels on Sheet two it re-orders those too. Any way around that?

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA Macro Order and Copy row when input integer

    Hi,

    Yes, but I need to understand whether there are also column labels on sheet1.

    This is clearly a much simplified example and probably doesn't represent the size of your actual data. We often find that when we give an answer to what is a trivial non representative example when the solution is used with the real world data it doesn't work because of factors like string length and other stuff which is important but hasn't been mentioned.

    Therefore upload your real workbook (or at least a cut down copy), and manually add the results you expect to see.

  8. #8
    Registered User
    Join Date
    08-16-2012
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: VBA Macro Order and Copy row when input integer

    Sorry, more detail both sheets will have headers. There inputted information ends in column H.

  9. #9
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA Macro Order and Copy row when input integer

    ..to avoid any misunderstanding would you upload a sample workbook please?

+ 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. VBA Macro Order and Copy row when input integer
    By bjohnsman in forum Excel General
    Replies: 0
    Last Post: 04-14-2017, 11:56 AM
  2. Need help adjusting the input type from Integer to Alphanumeric
    By mrdiet in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-28-2016, 12:04 PM
  3. [SOLVED] How to determine if the user input a STRING or an INTEGER?
    By mcmunoz in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-26-2013, 10:32 PM
  4. Formatting data input in order to use predefined macro
    By padrald0w in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-12-2013, 06:00 AM
  5. [SOLVED] Input Box must be integer, Cancel button type mismatch
    By Nrowell92 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-30-2012, 03:29 PM
  6. Validate input of user, Integer required
    By Gabor in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-03-2007, 06:45 PM
  7. Check that input in textbox is an integer
    By marcusr in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-26-2007, 01:01 PM

Tags for this Thread

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