+ Reply to Thread
Results 1 to 13 of 13

Insert Column after Last Inserted Column

  1. #1
    Registered User
    Join Date
    03-21-2014
    Location
    Russia, Moscow
    MS-Off Ver
    Excel 2013
    Posts
    39

    Insert Column after Last Inserted Column

    A simple macro:

    1.Run macro: Add a column after A (I have data at column B)
    -->Now column A:same, Column B: new blank, column C:previous column B
    2.Run macro again: Add a column after B
    ...
    3.Run macro again: Add a column after C
    ...
    Last edited by mariosmk555; 05-04-2014 at 06:31 AM.

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

    Re: Insert Column after Last Inserted Column

    Hi, mariosmk555,

    maybe like this:
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    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
    Registered User
    Join Date
    03-21-2014
    Location
    Russia, Moscow
    MS-Off Ver
    Excel 2013
    Posts
    39

    Re: Insert Column after Last Inserted Column

    Quote Originally Posted by HaHoBe View Post
    Hi, mariosmk555,

    maybe like this:
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Hello and thanks. How can I set the first column tha the macro will start from? Lets say C.
    Thanks again,

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

    Re: Insert Column after Last Inserted Column

    Hi, mariosmk555,

    no need for a full quote here according to Forum Rule#12.

    Only if Data exceeds Column C it would be of use here:
    Please Login or Register  to view this content.
    Starting at a certain range will not insert new columns prior to any filled cells, thatīs a different requirement.

    Ciao,
    Holger

  5. #5
    Registered User
    Join Date
    03-21-2014
    Location
    Russia, Moscow
    MS-Off Ver
    Excel 2013
    Posts
    39

    Re: Insert Column after Last Inserted Column

    Quote Originally Posted by HaHoBe View Post
    Hi, mariosmk555,


    Ciao,
    Holger
    Thanks for the fast response,
    maybe I didn't explain well my goal.

    I want to set a column: for example D (D and E are filled with data)
    I want to run macro: and create 2 columns after D and shift E two times right.
    When I run again the macro I want the new columns to be created after the previous two columns that macro created.
    etc..

    **Today is my first day with VBA and excel macro!

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

    Re: Insert Column after Last Inserted Column

    Hi, mariosmk555,

    you should be more precise in what you are asking. In the opening post it was one column (the last one) which should be shifted. Now itīs two columns, and Iīm not so sure about the columns you have used or the range where to insert:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Ciao,
    Holger

  7. #7
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Insert Column after Last Inserted Column

    You may try this code also.....
    The code will ask you to input the column of interest, so you need to input the column alphabet. Suppose you want to insert two column after the col. D, in that case you need to input either d or D in the input box.
    Please Login or Register  to view this content.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  8. #8
    Registered User
    Join Date
    03-21-2014
    Location
    Russia, Moscow
    MS-Off Ver
    Excel 2013
    Posts
    39

    Re: Insert Column after Last Inserted Column

    Hello again you are very helpful.
    I understand the code you wrote above.
    But I think that it can be done simpler but I do not have the time to implement the idea. So let me tell what I am thinking.

    Instead of using the first column as reference which means that we have to store the relative position after closing excel,

    is it possible to give a name on column "E"="SteadyColumn"? Because what I want is to always create two new columns before the "SteadyColumn"
    Doing that if we use as reference the named cell, it is simpler isn't it?

  9. #9
    Registered User
    Join Date
    03-21-2014
    Location
    Russia, Moscow
    MS-Off Ver
    Excel 2013
    Posts
    39

    Re: Insert Column after Last Inserted Column

    Quote Originally Posted by sktneer View Post
    You may try this code also.....
    The code will ask you to input the column of interest, so you need to input the column alphabet. Suppose you want to insert two column after the col. D, in that case you need to input either d or D in the input box.
    Please Login or Register  to view this content.
    Good idea but instead of giving the option to the user to choose the column,

    (I repeat what I said above), if we give a name to the column from which the new columns will always be created before it will be easier. Can we do that in macro?

    paint.jpg
    Last edited by mariosmk555; 05-04-2014 at 08:55 AM.

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

    Re: Insert Column after Last Inserted Column

    Hi, mariosmk555,

    mark the cell with the cursor, goto the NameWindow (where you see the Cell Address), put "SteadyColumn" (without quotes and blanks) and press Enter.

    Please Login or Register  to view this content.
    Stop quoting full posts, please! And if your Excel can convert pictures into Workbooks go ahead with posting pictures (my versions of Excel canīt do that).

    Ciao,
    Holger

  11. #11
    Registered User
    Join Date
    03-21-2014
    Location
    Russia, Moscow
    MS-Off Ver
    Excel 2013
    Posts
    39

    Re: Insert Column after Last Inserted Column

    Perfect!
    If you could also answer this question since you solved the problem, you will be extremely helpful.

    How I can copy information from another cell to the newly created columns but by refering to them not by their actual names but as the column which is 1 time left to steady column and 2 times left to steady column?

    This is only what I need: Range("SteadyColumn"-1) ..

    You are a pro mate!!
    Last edited by mariosmk555; 05-04-2014 at 09:18 AM.

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

    Re: Insert Column after Last Inserted Column

    Hi, mariosmk555,

    you should really make up your mind about what you want prior to asking questions and not alter the requirements on each post.

    Please Login or Register  to view this content.
    Ciao,
    Holger

  13. #13
    Registered User
    Join Date
    03-21-2014
    Location
    Russia, Moscow
    MS-Off Ver
    Excel 2013
    Posts
    39

    Re: Insert Column after Last Inserted Column

    Sorry but I don't really know how it works since is my first in the forum.

    Can you please elaborate on the code that you just wrote?

    Please Login or Register  to view this content.
    I want to paste the copied information from cells A1 and B1 on the two new columns. How do I do that using your code?
    Thanks again, and this is my last question on this post following your guidance.

+ 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. Add a checkbox to column whenever a new row is inserted
    By Phillips Contracting in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-11-2014, 01:44 PM
  2. Copy column sub-headings to inserted column via formula
    By Geppstar in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-13-2013, 05:36 PM
  3. Sum of columns to right - update when new column inserted
    By miro2021 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-21-2013, 11:00 AM
  4. Insert column and fill column upto where data is in previous column
    By aka189 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-24-2012, 06:07 AM
  5. AUTO INSERT A COLUMN'S FORMULA IN MANUALLY INSERTED ROWS
    By JLah in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-20-2006, 11:15 AM

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