+ Reply to Thread
Results 1 to 11 of 11

Help writing macro for +1 and -1 Columns (sample file attached)

  1. #1
    Registered User
    Join Date
    10-20-2012
    Location
    South Carolina
    MS-Off Ver
    Excel 2007
    Posts
    7

    Question Help writing macro for +1 and -1 Columns (sample file attached)

    Ok, so i'm attaching a simple sample of the file i'm playing around with.

    What i'm trying to do is make it so I can add a single new column with all the same data and formulas in order, so it stays in series.

    I know how to write a macro to do this, my problem is writing one that can keep adding, so like I activate the macro and it adds a new column then i hit it again and it adds another one directly after the one just added and so on and so on.

    I would also like a macro to do the same but in reverse, so when i'm done or if I add to many i can get rid of them by simply hitting the button.

    Thank you for any help!

    Further detail will be in the file attached.
    Attached Files Attached Files

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Help writing macro for +1 and -1 Columns (sample file attached)

    I think that this code should do what you want

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Registered User
    Join Date
    10-20-2012
    Location
    South Carolina
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Help writing macro for +1 and -1 Columns (sample file attached)

    Thanks! That does work.

    So, basic premis is down...now...what I REALLY need is to know how to do this myself? Im sorry if its asking alot but, is there a way you can do a step by step?

    Because I want to do this, but to add a column to multipule sheets inside the workbook at a time.

    If i know the process to do it for one worksheet, I can do it to multipule. THANK YOU SOOO MUCH if you can!

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Help writing macro for +1 and -1 Columns (sample file attached)

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-20-2012
    Location
    South Carolina
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Help writing macro for +1 and -1 Columns (sample file attached)

    I'm not trying to be picky but, I dont really understand that :-/

    By step by step, i meant like if i hit "record macro" what would I do? Just need for how to do what you did for one sheet, after that I can just move to the next sheet instead of stopping the macro recording.

    Thanks again,

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Help writing macro for +1 and -1 Columns (sample file attached)

    The problem with recording a macro is that it won't work in your situation.

    If you record your selecting the last column along with the column to the right, it would record your selection.
    But if you ran that macro it would select the same two columns, every time. The macro recorder can't do "last column".

  7. #7
    Registered User
    Join Date
    10-20-2012
    Location
    South Carolina
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Help writing macro for +1 and -1 Columns (sample file attached)

    Ok, so i've been playing with it and I cant seem to get it to work, just cant figure it out :-/

    So, here is the main file that I want to use. If you could please help me out and make that macro that can Add 1 column and take away 1 column from each worksheet all at once I would be soooo thankful! You have no idea lol!

    On every sheet where there is a "School #" All refer the the VERY FIRST instance of "School #" on the first sheet in row 2, and the 2nd instance of "School #" refers to the first one on that sheet, so for example

    Cell B2 on worksheet 2 is ='Personnel Inspection'!B2 then cell B42 on that same sheet is =B2. If you could please keep these formulas as well, I noticed it didnt the last time.


    The unlock password is DrillMeet
    BGDM Grader_Final_For_Help.xlsx
    Last edited by smitha6; 11-20-2012 at 11:25 AM.

  8. #8
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Help writing macro for +1 and -1 Columns (sample file attached)

    This macro will do all the worksheets in a work book

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    10-20-2012
    Location
    South Carolina
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Help writing macro for +1 and -1 Columns (sample file attached)

    Quote Originally Posted by mikerickson View Post
    This macro will do all the worksheets in a work book
    It doesnt, and I think it doesnt because not all the sheets in the workbook are the same as that very first one.

    I'm sorry if this is annoying or too hard/much work, :-/

  10. #10
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Help writing macro for +1 and -1 Columns (sample file attached)

    The attachment in post 7 is password protected. The password is different than in the previous attachment.

  11. #11
    Registered User
    Join Date
    10-20-2012
    Location
    South Carolina
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Help writing macro for +1 and -1 Columns (sample file attached)

    Yeah, I posted above the attachment the password, its DrillMeet

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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