+ Reply to Thread
Results 1 to 5 of 5

Macro to Copy One Collumn to the Next

Hybrid View

  1. #1
    Registered User
    Join Date
    12-08-2006
    Posts
    4

    Question Macro to Copy One Collumn to the Next

    Hi

    I have a spreadsheet I have setup which users are asked to fill out, to save some time for them I would like to have a button (or some sort of text link) that they could press, which would automatically copy the contents of the column to the left of it, and paste it into this column.

    I was wondering if someone could help me with the code to use for the macro, and if it is also possible to have text which can be clicked (or a button) which will run the Macro.

    Any advice is appreciated

    Thanks

    John

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi,

    Can you expand a bit.

    E.g If the user selects a cell in Col B you want to copy column C and paste into Col B ??

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    12-08-2006
    Posts
    4

    Explenation

    Sorry, what I mean is that they would be typing entries into the cells in Collumn B, I would then like to have text at the top of collumn C that said 'Copy contents from previous collumn' and when clicked it would copy every cell from B into the cell next to it in C. Then one above collumn D what would copy every cell from C, and so on.

    Thanks for your help

  4. #4
    Registered User
    Join Date
    12-08-2006
    Posts
    4

    Update

    I have played about with this and the macro I think I need is similar to this

    Columns("B:B").Select
        Selection.Copy
        Columns("C:C").Select
        ActiveSheet.Paste
    However this would mean I would have to have a seperate macro for each collumn (and there are lots in my spreadsheet). Is it possible to replace the B:B and C:C to replace them with the active collumn, and the one to the left of it.

    Also, is it possible to have the macro run on the click of text or a form button.

    Thanks

    John

  5. #5
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi,

    Try something like

    Sub Copy_ActiveCol()
    
    
    ActiveCell.EntireColumn.Select
    
    Selection.Copy
    
        ActiveCell.Offset(0, 1).Columns("A:A").EntireColumn.Select
        ActiveSheet.Paste   
        
    End Sub
    VBA Noob

+ 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