+ Reply to Thread
Results 1 to 8 of 8

A find and replace problem

  1. #1
    Registered User
    Join Date
    04-06-2012
    Location
    yok
    MS-Off Ver
    Excel 2010
    Posts
    4

    A find and replace problem

    Hello dear friends,
    I have a workbook that has almost 98 worksheets. I need guidance on a problem. I want to find specific cells on these worksheets and change their values and again find some cells and change the value of the cell next to it. I use macro recorder to do that but it works on active cells and active worksheet only. I tried to do a loop to go through other worksheets and failed. Below is the code that i tried to create.
    Please Login or Register  to view this content.
    This works but only on active worksheet.

    And my other question is, i am new to programming and vba. How can i learn this? I see some forum writers that write amazing codes. I know it takes time to learn that, but do i have to learn Visual Basic first? Because i have a lot of VBA e-books that many people say that those are good books. But i kind of feel that those books are incomplete. For example Code says "If range("a1:b5") is not....". How can i know that i can use "is not" in a code? And is there a complete list that VBA and Excel objects, methods and properties are explained? it can be a book suggestion about it...

    Any help would be extremely appreciated.

    Thank you,

    Best Regards...

  2. #2
    Valued Forum Contributor MaczaQ's Avatar
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    510

    Re: A find and replace problem - Help needed...

    in each sheet there is only one cell with serched value or there is more then one result for each sheet ?
    Are you able to provide dummy data file for show example data source ?
    Best Regards
    MaczaQ
    ---------------------------------------------------------------------------------------------------------------------------
    If you are satisfied with the solution(s) provided, please mark your thread as Solved
    If you are pleased with my answer consider to rate it. To thank someone who has helped you, click on the star icon below their name.
    - This way you will add him some reputation points ... thanks in advance.

  3. #3
    Registered User
    Join Date
    04-06-2012
    Location
    yok
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: A find and replace problem - Help needed...

    Thanks for the reply, maczaq;

    i attached a sample file, mainly the cells with "green" bakcgrounds need to be changed. But if i see a sample working code i think i can manage the rest.

    Thanks,

    Regards.
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    12-28-2011
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    280

    Re: A find and replace problem - Help needed...

    Hi

    You need to use your ws variable to ensure the code executes against each sheet:

    Please Login or Register  to view this content.
    For testing your Regular Expression patterns, try my Regular Expression Pattern Testing add-in!

    For notes on how to use it - see here.

  5. #5
    Registered User
    Join Date
    04-06-2012
    Location
    yok
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: A find and replace problem - Help needed...

    Thanks for the reply, but when i copied your code it gives error.
    Please Login or Register  to view this content.
    Basically i want this to run on all worksheets. Any thoughts?

  6. #6
    Valued Forum Contributor MaczaQ's Avatar
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    510

    Re: A find and replace problem - Help needed...

    try this
    Please Login or Register  to view this content.
    but this code will replace only first found cells with your value - if you will need complex replace consider to use below code:
    Please Login or Register  to view this content.
    Last edited by MaczaQ; 04-18-2012 at 01:44 PM. Reason: new code provided

  7. #7
    Registered User
    Join Date
    04-06-2012
    Location
    yok
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: A find and replace problem - Help needed...

    Thanks maczaq, first code seems to be working, second also works but not on some values, any way first one solves my problem, worst case i repeat that many times.
    I owe you a dinner

    What about my other question, i have no programming background, do i need to learn basic first, can you or someone reading this post recommend any books to learn VBA?
    Thanks a lot again.

    Best Regards.

  8. #8
    Valued Forum Contributor MaczaQ's Avatar
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    510

    Re: A find and replace problem

    You don't need to learn pure VB before you will start a trip with VBA. Also there is a bit different between each other.
    I can't recommend any book because I'm self learner ;-) I'm still learning because even if you will use that language there will be some not official or hidden so looking for answer on that forum is quite good for start and try to understand used codes. If you will need any support do not hasitate - It will be pleasent for me to help you to understand. I saw few books like "VBA for dummers" etc. but finaly if I should choose one then I will mark one from hand of John Walkenbach.

    p.s. probable when I will be some day in yok I will get mty dinner ;-)
    Good luck

+ 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