+ Reply to Thread
Results 1 to 10 of 10

Copy Paste number of rows using input from user

  1. #1
    Registered User
    Join Date
    10-10-2008
    Location
    Maastricht, The Netherlands
    Posts
    4

    Copy Paste number of rows using input from user

    Hi all,
    I have been struggling with a problem for a while and I believe VBA can help, but unfortunately my knowledge of excel VBA is limited. Anyway here is the problem:

    I have an excel file where users need to input sample data per row for a fridge storage system. This Inputsheet will be used to upload data into the storage systenm using a script. This script reads rows which contain data. In the sheet where the user is adding his data (called Inputsheet) I have formulas and data validation based on lists included. To make sure the cell values are correctly included in the other program, I have included them in rows 1-100. If the user is adding data of just 20 samples, the script still reads the formulas in rows 21-100 and therefore adds incomplete data.
    What I would like to see is that the user is asked (using an input box?) to indicate how many samples he wants to add (say 20) and that Excel copies the row (including the prefilled formulas and validation listst) from Sheet X to the Inputsheet which will then be pasted 20 times starting in cell A1.

    Thanks for any help.
    Rob

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Copy Paste number of rows using input from user

    Cmore77, are you able to provide a sample workbook illustrating what you want?
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy Paste number of rows using input from user

    Would something like this help to get you started?

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    10-10-2008
    Location
    Maastricht, The Netherlands
    Posts
    4

    Re: Copy Paste number of rows using input from user

    I have attached the file. A short explanation:
    - Inputsheet: row 3 contains the formula and dropdown selections
    - FIS export: this is the format necessary for the script to upload it in the fridge information system (FIS). The information is derived from the Inputsheet and slightly modified to allow the script to put the information in the correct database fields.
    The other 2 sheets contain the formula and validation fields for the Inputhseet and teh FIS export sheet.

    the steps:
    - Inputsheet and FIS export are blank, only headers are shown
    - input number of samples by user (eg.20)
    - Row 3 is copied from "Formula Tab Inputsheet" and "Formula Tab FIS export" and copied 20 times to resp. "Inputsheet" and "FIS export"
    - user completes details of 20 samples in Inputsheet (rows below R22 do not contain values or formulas or validation cells)
    - template is saved and uploaded to Fridge Information System manually.

    I hope this helps...
    Attached Files Attached Files

  5. #5
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Copy Paste number of rows using input from user

    Cmore,

    When you delete all the content from Inputsheet, the formulas in Formula Tab FIS export gets ruined. This is what I suggest:

    1. on your sheet Formula Tab FIS export, edit the formula, removing the "=" so that it is now just text... for example A1 would just have the text "Inputsheet!A3" Do this for the whole of row 3.
    then the code below will do what I think you want:
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    10-10-2008
    Location
    Maastricht, The Netherlands
    Posts
    4

    Re: Copy Paste number of rows using input from user

    Thanks Arkadi,

    this helps to some extent. I receive an error since not all cells can be switched back from text to formula in Tab FIS Export. eg. Cell E3 contains a different formula, so the VBA stops there...

  7. #7
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059
    I was at work when I worked on this so I dont have the file with me. When I tested the code I sent on the workbook it worked. Ill upload my version and we can see what is causing your error.

  8. #8
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Copy Paste number of rows using input from user

    Here is the file I used... I got no errors. Can you check it out and see if it works for you? Module 2 contains the macro I prepared.
    Attached Files Attached Files
    Last edited by Arkadi; 08-15-2016 at 12:00 PM.

  9. #9
    Registered User
    Join Date
    10-10-2008
    Location
    Maastricht, The Netherlands
    Posts
    4

    Re: Copy Paste number of rows using input from user

    Thanks Arkadi, your file works! Maybe I did something wrong when replacing the formulas with text. Anyway, this does the trick for me! And more importantly, it gives me more insights on how VBA works. Thanks a lot for your efforts

  10. #10
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Copy Paste number of rows using input from user

    My pleasure Cmore
    Please remember to mark the thread as solved if we are done? Bedankt!

+ 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. string macro for a user input button, copy and paste data from all sheets to summary
    By Lawleypops in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-15-2015, 11:17 AM
  2. string macro for a user input button, copy and paste data from all sheets to summary
    By Lawleypops in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-14-2015, 11:09 PM
  3. [SOLVED] Copy paste specific row of data based on user input
    By jjsiow in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-23-2014, 11:59 AM
  4. Creating User Input box or Vlookup to select column to copy and paste
    By TiPu1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-15-2013, 03:55 PM
  5. Please Help with Copy/Paste and creating sheets depending on user input
    By rrstull in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-06-2013, 05:43 AM
  6. Macro to Copy Rows based on User Input
    By CharterJP in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-24-2012, 06:13 PM
  7. Copy/Paste user input info into another worksheet
    By MarkExcelMark in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-13-2011, 04:18 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