+ Reply to Thread
Results 1 to 5 of 5

VBA: Change content of each sheet in an workbook

  1. #1
    Registered User
    Join Date
    09-12-2012
    Location
    Gothenburg
    MS-Off Ver
    Excel 2003
    Posts
    3

    VBA: Change content of each sheet in an workbook

    Hello.

    I am new to this forum and hope for a little help.

    I have searched the forum have, to my surprise, not found anything quite similar to my request. Perhaps it is too obvious?

    For every sheet in a workbook, I would like to replace cell contents. It is always the same for each sheet and the structure of each sheets is the same.


    I tried some permutations of the following syntax but to no avail.

    Please Login or Register  to view this content.
    Now there are two questions:
    1. What should I use to replace the ..... ?
    2. How do I specify a formula (where formula I want in C5 could be "=if($C$1="OK"; A5+B5; 0)" ?
    Edit: Figured the second one out.

    Extra bonus: How to do this for all workbooks in a directory or in the current directory.

    Optionally: If it is simpler, it is OK to copy a range from a template and paste into all sheets.

    Best regards
    Last edited by bongus; 09-12-2012 at 06:23 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: VBA: Change content of each sheet in an workbook

    Hello there, try the following:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-12-2012
    Location
    Gothenburg
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: VBA: Change content of each sheet in an workbook

    Thanks a lot.

    I'll see if anyone attacks the bonus question before changing status to solved.

  4. #4
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: VBA: Change content of each sheet in an workbook

    Hello there,

    Try this one, you'll need to change the red highlighted text to your filepath for the folder that contains the files you wish to loop through:

    Please Login or Register  to view this content.

    Code compliments of:
    http://stackoverflow.com/questions/5...d-pulling-data

  5. #5
    Registered User
    Join Date
    09-12-2012
    Location
    Gothenburg
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: VBA: Change content of each sheet in an workbook

    Thanks a million. It works.

    Noe I will sort out how to get ALL the operations in the loop to work in this context. I will not bother you with that, though.

    Best regards
    /Henrik Målberg

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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