+ Reply to Thread
Results 1 to 10 of 10

Macro to move a cell right every time it runs

  1. #1
    Registered User
    Join Date
    03-12-2008
    Posts
    5

    Macro to move a cell right every time it runs

    Hi

    I am new to this forum and know basic excel and i am runing Excel 2003.

    I have a spreadsheet with sales figures for a company over a few months. I want to create a macro that will insert a new month after the last month. I have got it to work for the first month but after that it will just insert 2 black cells after.

    i have a named cell called Average_slales_per_month that is next to the last month all the time.

    Any help would be much appreciated.

    i have hopefully attached the sheet to this thread

    Regards

    Stephen Mumford
    Attached Files Attached Files

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Wouldn't it be easier to creaste the necessary columns first & hide them. Code could then unhide columns according to the month.

    This wouldn't be a college project would it?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    03-12-2008
    Posts
    5
    Yes it is


    And I am afraid I have to demonstrate it in a macro

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Have you been asked to actually insert a column?

    What code have you used so far?

  5. #5
    Registered User
    Join Date
    03-12-2008
    Posts
    5
    i have beren asked to

    "create a macro to add a new colimn for sales datas to be inserted. This should insert relevant period details automaticallt and allow all exsisting statics to update without user input"

    i have attached the file with the macro i have been using
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243
    hi Stephen,

    Edit: Ooopps! I hadn't seen any of the posts after your first one when I posted this (if it wasn't for the fact that this is a project - Central Sussex College?, I would/still do strongly suggest redesigning the file as mentioned below or even to use a Pivot Table)...

    Original text:
    I've had a look at your file & I suggest moving your summary/calculated columns (ie col O to col R) to the left of the sheet eg b/n the existing columns B & C. This way the summary data is always visible at the left of the sheet (esp with the use of Freeze panes or "coolumns to repeat at left" in the printing options) - no matter how many months you keep records for.

    If you are still keen on a macro with the existing format try:
    Please Login or Register  to view this content.
    hth
    Rob
    Last edited by broro183; 03-12-2008 at 06:48 AM.
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  7. #7
    Registered User
    Join Date
    03-12-2008
    Posts
    5
    Please Login or Register  to view this content.

    Hi i have been loking at your code and i am very intrested how it works. could you explain step by step whet you did ..

    Also i need to make it so that it will update the formula that ill be dependet on the new colum cells

  8. #8
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243
    hi Stephen,

    Here's what the original code does:

    Please Login or Register  to view this content.

    Quote Originally Posted by mumford54
    Also i need to make it so that it will update the formula that ill be dependet on the new colum cells
    What do you mean (does it relate to the ".value = .value" line)?


    On rereading your first post I can see that the "Find" section isn't need & the code can then be shortened slightly to:

    Please Login or Register  to view this content.

    You may find the below links useful for learning more about Excel:
    http://www.excelforum.com/showthread.php?t=620254

    http://www.mvps.org/links.html#Excel

    hth
    Rob

  9. #9
    Registered User
    Join Date
    03-12-2008
    Posts
    5
    What do you mean (does it relate to the ".value = .value" line)?


    i don't think this is what is need but thanks any way

  10. #10
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243
    hi Stephen,

    Sorry, it seems we've confused each other. Does the current code do everything you want?

    If not, let us know...

    Rob

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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