+ Reply to Thread
Results 1 to 9 of 9

Code to Open A list of Path and copy a selected cell

  1. #1
    Registered User
    Join Date
    12-18-2010
    Location
    manila,philippines
    MS-Off Ver
    Excel 2003
    Posts
    7

    Exclamation Code to Open A list of Path and copy a selected cell

    Good day

    I would like to ask for a simple prog with macros, here's the deal,

    I have a list of paths in columns A range is A7:A63
    And now i want to open them one after the other for example....open path in A7 the close it then open A8 then close it and so on. Another things is, i want to copy a specific cell from these paths (sheet named DPL) and copy it in the workbook(sheets name Master) where the paths are.I have a code here please help where did i go wrong. I dont know how please help....Thanks


    Sub Button1_Click()
    Dim wb As Workbook
    Dim c As Range
    Dim rngTo As Range

    For Each c In Range("A5:A10").Cells
    Set wb = Workbooks.Open(Filename:=c.Value)
    ' do something with workbook wb
    With Workbooks("DPL").Sheets("C5").Value
    Set rngTo = .Range("B5" & .Rows.Count).End(xlUp).Offset(1, 0)
    End With
    wb.Sheets("Master").Range("C5").Copy rngTo
    wb.Close
    Next c
    End Sub
    Last edited by roipatrick; 12-18-2010 at 09:15 PM.

  2. #2
    Registered User
    Join Date
    12-18-2010
    Location
    manila,philippines
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Code to Open A list of Path and copy a selected cell

    Sorry, for the words
    Last edited by roipatrick; 12-19-2010 at 11:13 AM.

  3. #3
    Registered User
    Join Date
    12-18-2010
    Location
    manila,philippines
    MS-Off Ver
    Excel 2003
    Posts
    7

    Talking Re: Code to Open A list of Path and copy a selected cell

    I have this code, kindly tell me where i went wrong because i tried looping it but with no luck. This code just open workbook one only and i want to eliminate the opening 1 by 1 and all i want is to loop it to be able to open one workbook after the other but the copying will be the same..
    I want to is to open a list of workbook whose paths are list in column A range starts from A7 upto A66.
    Please Login or Register  to view this content.
    Please do provider where i will insert the looping.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Code to Open A list of Path and copy a selected cell

    You still need to put code tags around the code in post #1 (edit) or remove the code since you've duped it into another post. The rules should be followed without any complaining, they're meant to benefit all, including you. OK?

    Try this:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Registered User
    Join Date
    12-18-2010
    Location
    manila,philippines
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Code to Open A list of Path and copy a selected cell

    Thanks for the help. I would like to apologize if ever i failed to follow some rules and i will keep that in mind that these rules are set to all of us. Thank you and again im sorry.

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Code to Open A list of Path and copy a selected cell

    If you are just getting values from those various sheets, perhaps you don't need to open them.

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  7. #7
    Registered User
    Join Date
    12-18-2010
    Location
    manila,philippines
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Code to Open A list of Path and copy a selected cell

    Thank you mike but the code you gave just copy 1 cell. I need to copy different cell.

    Example.
    with your formula i can copy cell c5 to cell A7 onwards
    next it i also want to copy cell c6 to cell A8 onwards, just like the way your code copied c5 to A7 onwards.


    Thank you.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Code to Open A list of Path and copy a selected cell

    Mine didn't work? (see post #4)

  9. #9
    Registered User
    Join Date
    12-18-2010
    Location
    manila,philippines
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Code to Open A list of Path and copy a selected cell

    Good day,


    I mixed you advices and it turned out real good, thanks to you guys. Now i have another dillema, i want to open again a list of workbooks ranging A7:A63 one after the other. After opening the first one i want to save it, get a specific file and paste it to where the paths are then close it and open the second one and so on and so forth.

    Here's a sample for this.

    Worksheet1 Column A7:A63 - List of paths or workbooks
    When i press a button A7 path will activate, save it first, copy cell m11 from workbook to worksheet 1 column B then close it. Open A8 and so on. And when i press the button again it will do the same but this time it will copy the cell m11 to Column c. And when i press the button again for the third time i want cell m11 to be copied to column D.

    Here's a sample code.
    Please Login or Register  to view this content.

+ 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