+ Reply to Thread
Results 1 to 13 of 13

Automating this action over an entire workbook?

  1. #1
    Registered User
    Join Date
    06-02-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 365
    Posts
    59

    Automating this action over an entire workbook?

    Hi folks,

    I have a workbook that contains 12 worksheets (months).

    I want to automate the following operation:

    If i find a certain word in a cell, i want to enter a particular number in the cell immediately to its right.

    I'd also like to change the number in another cell of the same row to zero.

    So as an example, if i find the word "private" in A1, i want to enter the number "600" in B1, and change whatever number is in G1 to zero.

    This operation should only apply if the word ("private") is found in column A

    If possible, I'd like to run this operation across all worksheets in one go.

    Could anyone point me in the right direction of how to achieve this?

    Thanks!

    (here is a little dummy workbook with the problem mocked up)

    replace2.xlsx
    Last edited by More Cowbell; 12-17-2023 at 09:47 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: Automating this action over an entire workbook?

    A cell can only have a value or a formula, not both. If you want to change something and add something elsewhere, you will need VBA.

    You would have to loop through the sheets in the workbook and, within that loop, loop through the cells in column A testing them for the word "private"

    Are you ok with VBA?
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    06-02-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 365
    Posts
    59

    Re: Automating this action over an entire workbook?

    Thanks for the reply, i never heard of VBA before (pretty much a noob with excel) but i'm willing to learn!

  4. #4
    Registered User
    Join Date
    06-02-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 365
    Posts
    59

    Re: Automating this action over an entire workbook?

    Just a little bump on this one, if anyone could give me some pointers on this, i'd appreciate it!

  5. #5
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Automating this action over an entire workbook?

    Here are two different approaches to your goal. They look very similar but are actually different :

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    06-02-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 365
    Posts
    59

    Re: Automating this action over an entire workbook?

    EDIT....

    Many thanks, i got it working!

    Sorry, one thing that i should have made more explicit in my OP:

    I need this to work if the cell contains a certain word or number.

    This solution only works if the cell contents = the search term.

    I mean, if you use: If c.Value = "private", then, it should also work if the cell contains "private payment" ......... or "payment - Private".

    So, also not case sensitive.

    Sorry, i know i'm now asking a lot, but if i can get this working, it'll save me literally days of work!
    Last edited by More Cowbell; 12-19-2023 at 04:04 PM.

  7. #7
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Automating this action over an entire workbook?

    Please Login or Register  to view this content.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: Automating this action over an entire workbook?

    Code example:

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    06-02-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 365
    Posts
    59

    Re: Automating this action over an entire workbook?

    EDIT, next reply coming in a moment
    Last edited by More Cowbell; 12-20-2023 at 10:28 AM.

  10. #10
    Registered User
    Join Date
    06-02-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 365
    Posts
    59

    Re: Automating this action over an entire workbook?

    Thanks guys,

    Unfortunately i don't understand!

    @Logit, i don't see any practical difference with this new version you posted. If i enter "private" it works, if i enter "rivate" or "Private", it doesn't. But my issue is that it needs to work if the specified text is found anywhere in the cell, not if ONLY the specified text is found. And it also shouldn't be case sensitive (UPPER or lower case shouldn't matter).

    @TMS, i think maybe your code is meant to fix that? But i don't know how to apply it.

    Sorry guys, this is literally the first time i ever messed with VBA!

  11. #11
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,205

    Re: Automating this action over an entire workbook?

    Please Login or Register  to view this content.
    Click RUN button and enter search word e.g, Private

    See here ..... https://trumpexcel.com/visual-basic-editor/
    Attached Files Attached Files
    Last edited by JohnTopley; 12-20-2023 at 12:07 PM.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  12. #12
    Registered User
    Join Date
    06-02-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 365
    Posts
    59

    Re: Automating this action over an entire workbook?

    Thanks so much, that seems to work perfectly!

  13. #13
    Registered User
    Join Date
    06-02-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 365
    Posts
    59

    Re: Automating this action over an entire workbook?

    Hi folks,

    Happy new 2024!

    I have a question on how to make a tweak to this formula:

    What i want to do is do the same search as before, and if the text (letters or numbers, not CASE sensitive) is found, it will give the whole row a certain background color, like yellow.

    Is this possible to implement in a similar way?

    Thanks, hopefully, in advance!

+ 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. Automating Workbook to Log Incoming Enquiries
    By dive1082 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-13-2022, 04:00 AM
  2. [SOLVED] formula to auto populate entire workbook for a entire year
    By COURTTROOPER in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-15-2017, 02:06 PM
  3. Replies: 0
    Last Post: 02-14-2012, 12:34 PM
  4. Automating reading a cell's value & deleting its entire row if value true
    By CedarLake23 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-12-2008, 09:33 PM
  5. Automating a workbook ???
    By inktec in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-06-2006, 08:45 AM
  6. Automating a workbook ???
    By inktec in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-06-2006, 08:45 AM
  7. [SOLVED] Automating Word - Print one page not entire document!
    By quartz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-25-2005, 03:06 PM

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