+ Reply to Thread
Results 1 to 11 of 11

VBA Formula for copying cells and adding new ones

  1. #1
    Registered User
    Join Date
    05-02-2012
    Location
    Italy
    MS-Off Ver
    Excel 2003
    Posts
    27

    VBA Formula for copying cells and adding new ones

    Hello to everyone i am trying to program a button in excel so that it takes the data from a few cells and it copies them in a new file. What i would like to do is also to make excel verify that if there is already data written in the new cells to write the new ones in the row below. Can somebody help me pls?
    It's very important for my job.

  2. #2
    Registered User
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,160

    Re: VBA Formula for copying cells and adding new ones

    Sure. You will need to give some details.

    Name of the file from which data should be copied.
    Ranges / cells that need to be copied.
    Name of the file to which data should be pasted.
    Ranges where the data needs to be pasted.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    05-02-2012
    Location
    Italy
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: VBA Formula for copying cells and adding new ones

    Quote Originally Posted by arlu1201 View Post
    Sure. You will need to give some details.

    Name of the file from which data should be copied.
    Ranges / cells that need to be copied.
    Name of the file to which data should be pasted.
    Ranges where the data needs to be pasted.
    Okay
    Name of the file of origin: own shares.xls
    Cells to be copied: C3, C4,C5,C8,C9,C12, C13, C14, C15, I5, I9
    Name of the file destination: archive.xls
    And the cells must be copied everytime i press the button in a different row but in the order mentioned above from A to K.

    Is that all you need?

  4. #4
    Registered User
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,160

    Re: VBA Formula for copying cells and adding new ones

    Will the destination file be opened or should the macro open it?

  5. #5
    Registered User
    Join Date
    05-02-2012
    Location
    Italy
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: VBA Formula for copying cells and adding new ones

    the destination file should be opened by the macro

  6. #6
    Registered User
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,160

    Re: VBA Formula for copying cells and adding new ones

    Try this code.
    Please Login or Register  to view this content.
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose Tools | Macro | Macros
    Select a macro in the list, and click the Run button.

  7. #7
    Registered User
    Join Date
    05-02-2012
    Location
    Italy
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: VBA Formula for copying cells and adding new ones

    Everytime i press the button it asks the destination file
    where do i change so that i can always save on the same file?

  8. #8
    Registered User
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,160

    Re: VBA Formula for copying cells and adding new ones

    Change this
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    05-02-2012
    Location
    Italy
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: VBA Formula for copying cells and adding new ones

    just an information in case i would like to open the destination file everytime i save the data how should i put it?

  10. #10
    Registered User
    Join Date
    05-02-2012
    Location
    Italy
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: VBA Formula for copying cells and adding new ones

    so that everytime i press the button it automatically saves the data

  11. #11
    Registered User
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,160

    Re: VBA Formula for copying cells and adding new ones

    Drsteffa,

    If i understood you correctly, if you change the code given in post 8, the macro will automatically open the file from the path specified, it will do the updates and then you need to add this line before the "End Sub".
    Please Login or Register  to view this content.
    This will save your file in that path from where you opened it, so that next time, the updates can be done to the same file.

+ 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