Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Opening Excel file through excel

rakeshVBrakeshVB Posts: 1Member
[b][red]This message was edited by rakeshVB at 2003-11-19 2:45:31[/red][/b][hr]
Hi every body!

Presently I am working on Excel modules where i have to collect data from Excel File into separate excel file. i want read few cells in of particular files & collect the data in to master excel file. I don't want to go for DDE.

i prefer reading the content of one excel file from another excel file by writing a macro(VBA) in to it.

Can any body help me in writing a macro for reading the content of one file to another file, even a small sudo code will help me a lot.

any help will be highly appreciated


Thanks a lot in advance.

Rakesh


Comments

  • PavlinIIPavlinII Posts: 404Member
    : [b][red]This message was edited by rakeshVB at 2003-11-19 2:45:31[/red][/b][hr]
    : Hi every body!
    :
    : Presently I am working on Excel modules where i have to collect data from Excel File into separate excel file. i want read few cells in of particular files & collect the data in to master excel file. I don't want to go for DDE.
    :
    : i prefer reading the content of one excel file from another excel file by writing a macro(VBA) in to it.
    :
    : Can any body help me in writing a macro for reading the content of one file to another file, even a small sudo code will help me a lot.
    :
    : any help will be highly appreciated
    :
    :
    : Thanks a lot in advance.
    :
    : Rakesh
    :
    :
    :

    So, if I can understand:
    You're writing macro (for example in your Master file) and this macro will collect several cells from another workbooks, right?
    [code]Public Sub CollectMyData()
    Workbooks.Open "F:DocsMyDoc1.xls" [green]'If your docs aren't opend[/green]
    Workbooks.Open "F:DocsMyDoc2.xls"
    Workbooks("MyDoc1.xls").Activate [green]'Make sure you've got activated the first Doc, you can also use index (and control if the name is right - may be faster way[/green]
    Worksheets("Data").Activate [green]'If you have more than one sheet[/green]
    Range("B2:B10").Copy
    Workbooks("Master.xls").Activate
    Worksheets("w21").Activate
    [green]'This will paste all (like Ctrl+V or ReturnKey)[/green]
    Range("C11").Select
    Activesheet.Paste
    [green]'This will pasteSpecial (Edit/PasteSpecial..)[/green]
    Range("C11").PasteSpecial xlPasteValues [green]'For example only values[/green]
    [green]'And the same with the second (and any else workbook)[/green]
    blablabla

    [green]'And Closing is simply[/green]
    Workbooks("Master.xls").Close True
    Workbooks("MyDoc1.xls").Close False [green]'False if you won't save changes in theese workbooks[/green]
    Workbooks("MyDoc2.xls").Clsoe False
    End Sub[/code]
    This code expects that your file Master.xls contains this macro and this macro expects that you have that files... And it will take cells B2:B10, copy & pastes into your workbook Master...

    Hope I understood your problem.. More questions? Ask!

    Hope this will help

    PavlinII
Sign In or Register to comment.