+ Reply to Thread
Results 1 to 22 of 22

Display Cell B1 value in Sheet1 of all the workbooks in a "Sample" workbook

  1. #1
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Display Cell B1 value in Sheet1 of all the workbooks in a "Sample" workbook

    Hi All

    I have a workbook name Sample and I want the code to run when its opened and it should check the first sheet "Sheet1" in all the workbooks in the folder C:\Folder\Temp.

    And if the first sheet name is not "Sheet1" then just ignore that workbook and move to next workbooks. If the first sheet name is "Sheet1" in a workbook then store the value present in cell B1 in Sample workbook "Sheet1".

    So if there are 5 workbooks in the folder C:\Folder\Temp and two of them hasn't got first sheet named "Sheet1" then display value of B1 in rest of the 3 sheets to the "Sheet1" of "Sample workbook" one after another.

    I hope anyone can help me in this.

    Thanks

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Display Cell B1 value in Sheet1 of all the workbooks in a "Sample" workbook

    Where do you want the value applied in the sample workbook? Listed down column A? (A1, A2, A3, etc.)
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Display Cell B1 value in Sheet1 of all the workbooks in a "Sample" workbook

    Yes please. It would be great if the code copies those values in column A.

    Please help me in this.

    Thanks

  4. #4
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Display Cell B1 value in Sheet1 of all the workbooks in a "Sample" workbook

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Display Cell B1 value in Sheet1 of all the workbooks in a "Sample" workbook

    Thanks so much Solus for your help. The code works but if there are some other files like word document (.doc)in the folder "C:\Folder\Temp\" , then it gives an error message but I want the code to just ignore those files(e.g word and Power point files) and don't display any error message.

    Could you please help me in this?

    Thanks

  6. #6
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Display Cell B1 value in Sheet1 of all the workbooks in a "Sample" workbook

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Display Cell B1 value in Sheet1 of all the workbooks in a "Sample" workbook

    Thats brilliant Solus.Thanks a lot. That problem is resolved and now one more thing is sometimes in the folder few workbooks will be password protected so I even want the code to ignore workbooks which are password protected instead of asking me again and again to enter password of the particular workbook.

    Can this be done? Many thanks afor your help so far.

  8. #8
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Display Cell B1 value in Sheet1 of all the workbooks in a "Sample" workbook

    Protected how? You're not editing the workbooks that you're opening so workbook protection should not even be triggered.

    In the future please be very detailed as to your problem. That way the first solution can be a complete solution.

  9. #9
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Display Cell B1 value in Sheet1 of all the workbooks in a "Sample" workbook

    Hi Solus. There are few workbooks which when I open manually then I need to enable macros first and then it asks for password to enter. So when I run this code then it works fine for the workbooks which are not password protected but the ones with password display me a window to enter the password first. SO thats why I just want to ignore the workbooks which are password protected.

  10. #10
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Display Cell B1 value in Sheet1 of all the workbooks in a "Sample" workbook

    Maybe:
    Please Login or Register  to view this content.
    Untested.

  11. #11
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Display Cell B1 value in Sheet1 of all the workbooks in a "Sample" workbook

    It still asks for the password for the protected workbooks.

    Any suggestions?
    Thanks

  12. #12
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Display Cell B1 value in Sheet1 of all the workbooks in a "Sample" workbook

    Please Login or Register  to view this content.
    for example. Password will be ignored for files without password and error will be handled for wrong password if workbook has password (we must assume password is not really "")
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  13. #13
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Display Cell B1 value in Sheet1 of all the workbooks in a "Sample" workbook

    Hi izandol

    When I run this code then it gives me run time error "Invalid password..." etc.. But in actual I want the code that will just ignore the workbooks with password on and don't ask me any password.

    Any suggestions?

    Thanks

  14. #14
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Display Cell B1 value in Sheet1 of all the workbooks in a "Sample" workbook

    You will only see this if you have VB Editor set to break on all errors - this will defeat On Error lines. If you may not change this, there is no solution, I think.

  15. #15
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Display Cell B1 value in Sheet1 of all the workbooks in a "Sample" workbook

    Izandol why there are 3 End if statements? This might be causing the problem? Could you please check the code again?

    Many Thanks

  16. #16
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Display Cell B1 value in Sheet1 of all the workbooks in a "Sample" workbook

    Is paste error - remove first or second one. (but if you have extra End If in code, you will not see password error because it will not run!)

  17. #17
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Display Cell B1 value in Sheet1 of all the workbooks in a "Sample" workbook

    Now I am getting runtime error '-2147221080(800401a8)' Automation error in the following line:

    If wbSource.Sheets(1).Name = "Sheet1" Then

  18. #18
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Display Cell B1 value in Sheet1 of all the workbooks in a "Sample" workbook

    I do not know how that will happen. May you post the code you are using now?

  19. #19
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Display Cell B1 value in Sheet1 of all the workbooks in a "Sample" workbook

    Please see the code below.

    Please Login or Register  to view this content.

  20. #20
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Display Cell B1 value in Sheet1 of all the workbooks in a "Sample" workbook

    You may try:
    Please Login or Register  to view this content.

  21. #21
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Display Cell B1 value in Sheet1 of all the workbooks in a "Sample" workbook

    You are genius..Thanks a lot . It worked perfectly fine..

  22. #22
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Display Cell B1 value in Sheet1 of all the workbooks in a "Sample" workbook

    You are welcome.

    Please remember to select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. [SOLVED] If there is any text in column "A$" on "sheet1" then move cell to column "A$" on "sheet2"
    By ckgeary in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-27-2013, 08:28 PM
  2. Replies: 0
    Last Post: 09-12-2011, 05:20 PM
  3. Replies: 0
    Last Post: 01-04-2006, 06:55 PM
  4. use variable in Workbooks("book1").Worksheets("sheet1").Range("a1"
    By Luc in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-28-2005, 04:05 PM
  5. [SOLVED] Sheets("sheet1").Range command between workbooks
    By Luc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-27-2005, 09:05 AM

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