+ Reply to Thread
Results 1 to 13 of 13

Macro to reference data from one sheet to another

  1. #1
    Registered User
    Join Date
    11-08-2007
    Posts
    8

    Macro to reference data from one sheet to another

    Hello all!

    I have a project that I'm going to attempt to handle, unfortunately I have no idea where to start. So any ideas or input to get me in the right direction would be greatly appreciated!! I am new to macro programming in excel and have a very light background in programming.

    What I have:

    Right now I have a data file(Sheet1) that lists the data of various accounts. Each row is a different account and each column is data that pertains to the account. Ex. Row 1 will be account # 1, with things like name, account number, address, etc... in columns A B C and so on.

    What I want to do:

    I need to make forms for EACH account in another sheet (sheet2), and in that form i need to reference specific data from Sheet1. THe reason it needs to be referenced is beecause if we make changes to Sheet1, the form will also need to be updated. Also, I dont need all the data in sheet one for each account, I will be pulling out data from different columns, ie. only columns A, E, F, etc...

    Please let me know if anything is unclear and if you can help in any way! Thanks

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Rather than having a form for each and every account, why not have one form, be able to select the account, then bring in the data relevant to that account? Can be coded with functions and doesn't need to have any macros.

    Perhaps build an example workbook with 2 sheets. Sheet1 has representative data, and sheet2 has a mock up of your form. Attach this to the post so we have some idea of what you are working with.


    rylo

  3. #3
    Registered User
    Join Date
    11-08-2007
    Posts
    8
    Thanks for the response Rylo!

    The reason why I need a form for every account is due to the fact that evenetually I will need to be able to scroll down and look at each and every form to make sure everything is correct. Thus it would be nice to have an individual form for each account. I will also be printing out all these forms at once. In the end there will be over 1000 accounts and thus 1000 forms.

    I've attached a mock up of what I'm currently working with. The Data File Sheet contains all the information while the form will only display specific data from the data file. The data file will be updated on a continual basis, and in turn I will need a macro that will be able to update the form based on these updates to the data file sheet.

    Thanks for any help you can provide!
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    11-08-2007
    Posts
    8
    I also forgot to mention that I will be needing to make absolute references to the data file, as cells in the data file may move around etc (by sorting/filtering)

  5. #5
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    I'm running Excel 2003. Can you convert the file, and reload.


    rylo

  6. #6
    Registered User
    Join Date
    11-08-2007
    Posts
    8
    Here is the file in 2003 format


    edit: I have attached the updated version
    Attached Files Attached Files
    Last edited by dushuodai; 11-09-2007 at 04:25 PM. Reason: attached updated version

  7. #7
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    HI

    Can you fill in one of the forms (say the first one on the Account Sheet) showing where you want the output data to go. For instance, the Tracking number could go into B3 or B6. Just so we can be sure where the data is coming from, put in formulas showing the source. So if the tracking number was going into B3, then the formula in B3 would be ='Data File'!A2

    Just remove the existing sample file, and attach an adjusted one.


    rylo

  8. #8
    Registered User
    Join Date
    11-08-2007
    Posts
    8
    File has been attached

  9. #9
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    See if the attached gets you there.

    rylo
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    11-08-2007
    Posts
    8
    Rylo,

    You are amazing. Thank you so much!

    However, I was wondering if you could help explain a couple lines of the coding so I can tweak the code a little more.

    Please Login or Register  to view this content.
    So above is the code that you wrote for my macro.

    Right now Im trying to understand what is going on here:

    Please Login or Register  to view this content.
    Could you give me some insight on what you are passing on through the Range Object and why?


    and also here:

    Please Login or Register  to view this content.
    for the For Each...Next loop, I dont understand what "ce" is but I do understand the pasting part.


    Is there a reason why the template starts with the data at the bottom of "data file"?

    Thanks for your time, you've been EXTREMELY helpful!!
    Last edited by dushuodai; 11-09-2007 at 07:52 PM.

  11. #11
    Registered User
    Join Date
    11-08-2007
    Posts
    8
    Does the copy and pasted output sheet match the formatting when you do it?

    Im wondering if it is an issue between excel 2007 and 2003. My output loses the spacing formatting that exists in the "template."

    I guess a more specific question is can you make the macro paste so it "Keep Column Source Widths" ??

    Thanks Rylo
    Last edited by dushuodai; 11-09-2007 at 08:12 PM.

  12. #12
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    I've added some rows to the code to format the rows and columns.

    See if that fixes things for you.

    Please Login or Register  to view this content.
    rylo

  13. #13
    Registered User
    Join Date
    11-08-2007
    Posts
    8
    Works great!! Thank you for all your help!!

+ 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