+ Reply to Thread
Results 1 to 10 of 10

Copy and insert column that contains vba code

  1. #1
    Registered User
    Join Date
    10-04-2017
    Location
    North Carolina
    MS-Off Ver
    2013
    Posts
    29

    Copy and insert column that contains vba code

    Hello all, I am extremely new to vba and using it in excel, please use small words I am creating a note-taking worksheet for which the design is a column for the user to note certain features of an item. The column contains several ActiveX comboboxes. I have learned how to insert vba code to allow the user to tab into and out of the comboboxes as they move down the column for ease of end-use. The code I've entered works - yay! My problem arises from the fact that the end-users will need more than one of these columns based on the number of items they are documenting - this is never a set number (otherwise I would just do all the coding on my end now) and can range from 1 to 50 or so (I don't want to do all that coding!) Is there a way for the end-user to enter design mode and copy the existing column, insert a copy of the column, and have the code copy also so that the new column allows the tabbing in and out too?

    If it helps, the code I've inserted is this:
    To key into a combobox:

    Please Login or Register  to view this content.
    To key out of a combobox:

    Please Login or Register  to view this content.
    In these examples, D9 is the underlying cell for ComboBox 16. Any help would be appreciated!!

    Cross-post: https://www.mrexcel.com/forum/excel-...-vba-code.html
    Last edited by jrooney7; 10-09-2017 at 07:03 PM. Reason: Cross post requirement

  2. #2
    Registered User
    Join Date
    10-04-2017
    Location
    North Carolina
    MS-Off Ver
    2013
    Posts
    29

    Re: Copy and insert column that contains vba code

    Bump no response

  3. #3
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,905

    Re: Copy and insert column that contains vba code

    For stuff like this I would design a userform and copy all data from that userform to the next available empty column.
    Then clear userform for next entry, and so one .....
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  4. #4
    Registered User
    Join Date
    10-04-2017
    Location
    North Carolina
    MS-Off Ver
    2013
    Posts
    29

    Re: Copy and insert column that contains vba code

    I will look into userforms, thank you! In the meantime, I am attaching a sample of my workbook - maybe getting a look at it would help...
    Attached Files Attached Files

  5. #5
    Administrator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs
    MS-Off Ver
    MS Office 365 Win 11 Home 64 Bit
    Posts
    21,888

    Re: Copy and insert column that contains vba code

    crossposted: https://www.mrexcel.com/forum/excel-...-vba-code.html

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).
    Alan


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,905

    Re: Copy and insert column that contains vba code

    I've put something together for you.
    Design and layout is for you to do, this is just functional.
    Attached Files Attached Files
    Last edited by bakerman2; 10-11-2017 at 07:01 AM.

  7. #7
    Registered User
    Join Date
    10-04-2017
    Location
    North Carolina
    MS-Off Ver
    2013
    Posts
    29

    Re: Copy and insert column that contains vba code

    This is fantastic! I tried it out and it works great! I have one question though - I cleared out Column C (the comboboxes and checkbox I had there originally) so that the userform would populate there first. But when I tried it, the data from the userform went to Column B. Looking at the code (and being very inexperienced), I'm not sure how to change that, but I figure it's this line:

    Please Login or Register  to view this content.
    I've attached a copy so you could see. Thank you for your help!
    Attached Files Attached Files
    Last edited by jrooney7; 10-11-2017 at 10:13 AM.

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,905

    Re: Copy and insert column that contains vba code

    Replace existing code with this one.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    10-04-2017
    Location
    North Carolina
    MS-Off Ver
    2013
    Posts
    29

    Re: Copy and insert column that contains vba code

    Thank you so much - that is perfect! I really appreciate your help!

  10. #10
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,905

    Re: Copy and insert column that contains vba code

    You're welcome and thanks for rep+.

+ 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: 10
    Last Post: 08-05-2016, 07:31 AM
  2. [SOLVED] Adapt copy and insert VBA code to ask how many times your would like it to copy and insert
    By Jamidd1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-10-2016, 04:59 PM
  3. [SOLVED] Copy Column as Selection and Insert to the next Empty Column MACRO
    By kaurka in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 04-22-2013, 12:50 PM
  4. Vba - find next empty column, insert column, copy paste values & copy paste formulas
    By DoodlesMama in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-20-2012, 12:43 PM
  5. [SOLVED] VBA Code - Copy & Insert copy to another worksheet.
    By ABAUS in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-17-2012, 01:39 AM
  6. Code to insert and copy down
    By Stevedarby02 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-18-2010, 11:50 AM
  7. [SOLVED] Need help with copy rows and insert code...
    By MrFleming007 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-15-2009, 06:01 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