+ Reply to Thread
Results 1 to 21 of 21

Help in sheets and workbooks

  1. #1
    Registered User
    Join Date
    01-18-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    89

    Help in sheets and workbooks

    Hi ... Is this Possible...
    I have 3 workbks (one,two,three)... and in that sheet 3 of each has consolidate data... Now I want in 4 th wrkbk all the three sheets from sheet 3 in each bok... any idea...

    eg: one.xlsx = sheet 1,sheet2,sheet3
    two.xlsx= sheet1,sheet2,sheet3
    three.xlsx=sheet1,sheet2,sheet3

    fur.xlsx= one!sheet3,two!sheet3,three!sheet3

    Thank U

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Help in sheets and workbooks

    Are one.xlsx to three.xlsx saved in one particular folder?

    Will it always be 3 workbooks or can the number increase in future?
    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
    01-18-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    89

    Re: Help in sheets and workbooks

    yes. All are in same folder. Again yes, in future it may increase. And when I change data in that sheet, then the duplicate sheet also to be change.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Help in sheets and workbooks

    So in future, if your files increase, only sheet3 from each file should be consolidated right?

    Is your file named "Sheet3" or something else in each file?

  5. #5
    Registered User
    Join Date
    01-18-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    89

    Re: Help in sheets and workbooks

    yes. The sheet name 'te1','te2'....and so

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Help in sheets and workbooks

    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

    The output will be in a new workbook. You can place this code in any file except the files to be consolidated.

  7. #7
    Registered User
    Join Date
    01-18-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    89

    Re: Help in sheets and workbooks

    not work. Error. Subscribt out of range

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Help in sheets and workbooks

    Is the error coming on this line ?
    Please Login or Register  to view this content.
    You told me the sheets are named as "te1", "te2", etc. So i put te3 there since you want sheet 3. So change the te3 in the above line to whatever sheet you need consolidated.

  9. #9
    Registered User
    Join Date
    01-18-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    89

    Re: Help in sheets and workbooks

    its work. Thank u so much. But I want when the data changed in original sheet, then it automatically changed in duplicate too...

  10. #10
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Help in sheets and workbooks

    In the case of changes, you need to run the macro again.

  11. #11
    Registered User
    Join Date
    01-18-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    89

    Re: Help in sheets and workbooks

    when I run macro it copied but each sheet copied in difft wrkbuk. But I want all the sheet3 in a single book.

  12. #12
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Help in sheets and workbooks

    You mean, the first time it ran fine? But when you made changes and ran it again, it ran in a different workbook?

  13. #13
    Registered User
    Join Date
    01-18-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    89

    Re: Help in sheets and workbooks

    yes. Exactly

  14. #14
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Help in sheets and workbooks

    Correct. Each time you run the macro, it will create a new workbook for you with the updated data. So you have to just discard the old data.

    Or we can ask the macro to pick up the file and clear all the sheets and then load. Which option do you want?

  15. #15
    Registered User
    Join Date
    01-18-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    89

    Re: Help in sheets and workbooks

    I want second option

  16. #16
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Help in sheets and workbooks

    Try this code
    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    01-18-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    89

    Re: Help in sheets and workbooks

    ok. I will try. Now I am with mobile. Thank 4 ur support. Later I will write the result. Once I thank you

  18. #18
    Registered User
    Join Date
    01-18-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    89

    Re: Help in sheets and workbooks

    HI Can u explain little
    what are these which is to be copy file path,


    'The folder containing the files to be recap'd
    myPath = "B:\Test"

    'Finds the name of the first file of type .xls in the current directory
    CurrentFileName = Dir(myPath & "\*.xlsx")

    'Create a workbook for the recap report
    Set Master = Workbooks.Open("B:\Report\Master.xlsx")


    Set sourceData = sourceBook.Worksheets("te3")= every time do I change sheet name if so...

  19. #19
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Help in sheets and workbooks

    'The folder containing the files to be recap'd
    myPath = "B:\Test"
    This is the path which contains your files which need to be consolidated

    'Finds the name of the first file of type .xls in the current directory
    CurrentFileName = Dir(myPath & "\*.xlsx")
    You do not need to change this. Except the file extension if you are using excel 2003 files or others. This statement saves the filename including the path in the Currentfilename variable.

    'Create a workbook for the recap report
    Set Master = Workbooks.Open("B:\Report\Master.xlsx")
    This opens the master workbook and names it as "Master" so its easy to refer to it anytime in the code.

    Set sourceData = sourceBook.Worksheets("te3")= every time do I change sheet name if so...
    If its just one sheet name, you can change it above. However, if you need to consolidate multiple sheet names each time, we can change the code slightly for that. For e.g. if you want all sheet1 to be consolidated in master file sheet1, all sheet2 to be consolidated in sheet2, etc.

  20. #20
    Registered User
    Join Date
    01-18-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    89

    Re: Help in sheets and workbooks

    hey, thanks man. You did a nice job. Thanks again

  21. #21
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Help in sheets and workbooks

    Thank you.

+ 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