+ Reply to Thread
Results 1 to 7 of 7

Help with copying info from one excel to another in one action (Attachments)

  1. #1
    Registered User
    Join Date
    08-10-2011
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2007
    Posts
    16

    Exclamation Help with copying info from one excel to another in one action (Attachments)

    Hello and Happy New Year Excel Geniuses!

    I have constructed a code that I gathered from some other work I have performed and I am really close to having it do what I want.

    Attached are two files (FileToOpen & FileWithVBA).
    On FileToOpen there are two tabs with data "Before" and "After"
    On FileWithVBA there are the same tabs, but there is no data save for the headers of the columns.

    There is a button on FileWithVBA that when clicked, asks the user to open a file. If you select FileToOpen it will run code and then it will ask you again to open a file (click FileToOpen again) and when this is completed, the information from FileToOpen will be transported to FileWithVBA.

    What I am trying to accomplish is I want FileWithVBA to complete BOTH codes with only clicking the file one time. I have tried a variety of codes and keep getting errors about already compiling or naming components.
    If you save the two files and run the code, you will see what I mean by clicking the FileToOpen more than once.

    Couple things:
    1.) Can't create code with "FileToOpen" in the code because the name of the file for this code will be different for each person, hence why I need to have the user select a file.
    2.) Can't transport the sheet because I need the information copy and pasted, not moved.

    if someone can figure out how to make both run without selecting the file twice, I would be super appreciative! Thanks for looking!
    Thank you!!!
    Attached Files Attached Files

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,523

    Re: Help with copying info from one excel to another in one action (Attachments)

    I see what you mean, but don't know what all that code is supposed to do.

  3. #3
    Registered User
    Join Date
    08-10-2011
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Help with copying info from one excel to another in one action (Attachments)

    If you open FileWithVBA you will see that the Before and After tabs are blank.

    When you click the button it runs two macros. The first macro takes the data from the file selected (FileToOpen) and copies and pastes the data from sheet to sheet (Before-FileToOpen to Before-FilWithVBA). The second code does the same but for the After tab (After-FileToOpen to After-FileWithVBA). However, the code now requires the user to select the file more than once. If you notice, after you select the button and click FileToOpen twice, the Before and After tabs on FileWithVBA are no longer blank.

    I am trying to figure out how to do this without clicking FileToOpen more than once. The file I am using this code I need to do this for 20+ sheets and would like to be able to figure out how to do this without clicking the file 20+ times.

    Does this answer your question?

  4. #4
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: Help with copying info from one excel to another in one action (Attachments)

    Why dont you just combine them in one sub??? Like I did below... I didnt see this before I posted my question and I think it will help me solve mine as well so thought I would try to help you out.

    This will only make you call the file one time and do both???? Remember to delete the Call BeforeToBefore in the main sub...

    Please Login or Register  to view this content.

  5. #5
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,523

    Re: Help with copying info from one excel to another in one action (Attachments)

    Try this out.
    Please Login or Register  to view this content.
    Last edited by davesexcel; 01-02-2015 at 06:23 PM.

  6. #6
    Registered User
    Join Date
    08-10-2011
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Help with copying info from one excel to another in one action (Attachments)

    Thanks Corey (and davesexcel)!!

    I appreciate the time you both took to help me!
    Corey, I was trying to do that but kept getting errors! Yours worked for me! Dunno what I was doing wrong, but THANK YOU!!!

  7. #7
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,523

    Re: Help with copying info from one excel to another in one action (Attachments)

    Nothing in my code should have caused your computer to freeze.

+ 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. Extract XLS* attachments from select mails, save mail info into fields
    By Alteregoist in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-14-2013, 05:35 AM
  2. Replies: 1
    Last Post: 04-02-2010, 06:14 AM
  3. Copying excel info to notepad
    By shawnbecklar in forum Excel General
    Replies: 2
    Last Post: 12-11-2009, 11:07 PM
  4. VBA keyboard action, formatt no, no info windows
    By ineedhelp2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-15-2005, 03:00 PM

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