+ Reply to Thread
Results 1 to 15 of 15

New to VBA, simple copy and paste range of cells based on input box, NEED HELP

  1. #1
    Forum Contributor
    Join Date
    03-17-2017
    Location
    Alberta, Canada
    MS-Off Ver
    Microsoft Office Professional Plus 2010
    Posts
    130

    New to VBA, simple copy and paste range of cells based on input box, NEED HELP

    Here's what I got

    Please Login or Register  to view this content.
    How do I make it use the input number to copy and paste it that many times
    also would like the input box to open when workbook starts, or at the very least with hotkeys.
    I would like the Info from range "A7:H20" to be pasted below H20 with H21 being blank and this to be repeated based on the number input into the inputbox

    Thanks!
    Last edited by PNick; 04-11-2017 at 04:12 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: New to VBA, simple copy and paste range of cells based on input box, NEED HELP

    Hi,

    Unfortunately your post does not comply with Rule 3 of our Forum
    RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    In addition when you do edit your original I suggest you upload an example showing a before and after. It's not clear where the copied ranges should be pasted and whether if they're formulae you want to retain the formulae or values only.

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    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
    Forum Contributor
    Join Date
    03-17-2017
    Location
    Alberta, Canada
    MS-Off Ver
    Microsoft Office Professional Plus 2010
    Posts
    130

    Re: New to VBA, simple copy and paste range of cells based on input box, NEED HELP

    No help? Or is my question still unclear? Would really prefer not to attach workbook, as it contains confidential information, may have to just make an example if needed.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: New to VBA, simple copy and paste range of cells based on input box, NEED HELP

    In brief ...

    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Forum Contributor
    Join Date
    03-17-2017
    Location
    Alberta, Canada
    MS-Off Ver
    Microsoft Office Professional Plus 2010
    Posts
    130

    Re: New to VBA, simple copy and paste range of cells based on input box, NEED HELP

    You almost did it for me! Thanks!
    It creates one too many copies.
    And how do I get it to prompt you upon opening the workbook

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: New to VBA, simple copy and paste range of cells based on input box, NEED HELP

    You said
    How do I make it use the input number to copy and paste it that many times
    Is it not doing that?

    Q2: call the macro in the workbook open Event handler.

  7. #7
    Forum Contributor
    Join Date
    03-17-2017
    Location
    Alberta, Canada
    MS-Off Ver
    Microsoft Office Professional Plus 2010
    Posts
    130

    Re: New to VBA, simple copy and paste range of cells based on input box, NEED HELP

    You are correct, my question never asked what I wanted it to. The cells its copying counts as 1, then if we input the number 3 I want it to paste 2 more copies.
    Also I don't know where or how to "call the macro in the workbook open Event handler".

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: New to VBA, simple copy and paste range of cells based on input box, NEED HELP

    Please Login or Register  to view this content.

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: New to VBA, simple copy and paste range of cells based on input box, NEED HELP


  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: New to VBA, simple copy and paste range of cells based on input box, NEED HELP

    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    03-17-2017
    Location
    Alberta, Canada
    MS-Off Ver
    Microsoft Office Professional Plus 2010
    Posts
    130

    Re: New to VBA, simple copy and paste range of cells based on input box, NEED HELP

    You did it! Thanks! You never quite spelled it out for me, but I somehow fumbled through.
    Now how would I paste 3 other things underneath of the amount of copied cells previously determined by the inputbox
    The 3 other things are on their own sheets, titled "ADA", "OSBL NG", "T&D ROW".
    the cells to be copied are as follows:
    sheet ADA cells A5:H20
    sheet OSBL NG cells A5:H10
    Sheet T&D ROW cells A5:H11

    I would also like to keep one blank row between these newly pasted cells, and all formatting of the new cells to be pasted.

    If you could pull that off that is all I will ask. My worksheet will be complete, I will be a hero at the office, and you will be my hero.

    Thanks for everything!

  12. #12
    Forum Contributor
    Join Date
    03-17-2017
    Location
    Alberta, Canada
    MS-Off Ver
    Microsoft Office Professional Plus 2010
    Posts
    130

    Re: New to VBA, simple copy and paste range of cells based on input box, NEED HELP

    UPDATE:
    I compiled everything else I want pasted under the input box information onto a new sheet "sheet1" and tried this code

    Please Login or Register  to view this content.
    It never worked. Can you fix this for me.. probably wayyy off, but it was my attempt

  13. #13
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: New to VBA, simple copy and paste range of cells based on input box, NEED HELP

    You've kind of moved on from what was a relatively simple copy and paste to something a little more complex.

    It's essentially the same principle locate the last row and copy something and post it two rows further down. Repeat for each of the three sheets.

    ... and you will be my hero.
    Sadly, my cape is in the wash

  14. #14
    Forum Contributor
    Join Date
    03-17-2017
    Location
    Alberta, Canada
    MS-Off Ver
    Microsoft Office Professional Plus 2010
    Posts
    130

    Re: New to VBA, simple copy and paste range of cells based on input box, NEED HELP

    After writing my first post I realized that I could just make one sheet with everything on it that needed to be added to the end.

    All I now need it to do is to copy contents from "sheet 1" cell "A7:H20" and paste it into sheet "INSP" underneath the last cell (with a blank row between)

    But if you are admitting defeat, I still greatly appreciate the effort and you have been very helpful in getting me this far!

    Thanks

  15. #15
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: New to VBA, simple copy and paste range of cells based on input box, NEED HELP

    Please post a sample workbook as suggested in Post #2. This needs to show the starting point, that is, what is in Sheet1 and Sheet: INSP at the start (when the workbook opens).

    It's not a case of admitting defeat ... it's easy enough to do what I think you are asking for, I just don't know where you are starting from and where you want to end up. Bear in mind that you originally asked for cells A7:H20 to be copied and pasted the number of times indicated in the InputBox; then you said that the original cells counted as one of the copies. Then you said copy those cells and add other cells from three other worksheets. Now it's all in one worksheet so, presumably, we're back to the original number of repetitions ... but who knows?

    Given that you wanted A7:H20 copying in your original request, it seems odd that you still want A7:H20 copying even though there are, in theory, more cells now.

    I'm not really interested in producing code while you design "on the fly".

    In essence, all you need to do is adjust the source and target worksheets in the Copy and Paste.

    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. Replies: 3
    Last Post: 03-31-2017, 02:43 PM
  2. [SOLVED] Solution to copy a range of cells and paste in another Worbook w/o using an input box
    By kwesmc1 in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 03-29-2017, 06:41 PM
  3. Cut and paste a range of cells based on user input
    By MICHAEL BIZ in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-24-2015, 01:51 PM
  4. Replies: 3
    Last Post: 11-26-2013, 04:53 AM
  5. Replies: 1
    Last Post: 11-25-2013, 09:30 AM
  6. [SOLVED] Simple Macro required to Copy and Paste to the next cells in a range
    By scassells in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-05-2012, 12:06 PM
  7. Copy & Paste Range of Cells Based On Combo Box Value
    By medihx in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-30-2011, 04:43 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