+ Reply to Thread
Results 1 to 12 of 12

Macro to change any occurence of a value in a workbook

  1. #1
    Registered User
    Join Date
    08-29-2012
    Location
    Scotland
    MS-Off Ver
    Excel 2010
    Posts
    84

    Macro to change any occurence of a value in a workbook

    I would like to write some code for a macro button. Each worksheet in my workbook contains a reference letter in column A. If any cell in column A ="SB" I want to replace it with "AB".
    Anyone help me with how I can do this.
    Need it to chage on all worksheets.

  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,457

    Re: Macro to change any occurence of a value in a workbook

    You don't need a macro to do that.

    Just select all the sheets. Then select column A by clicking on the Column Header (not cell A1).

    Then do a global replace of SB to AB


    Regards, TMS
    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
    08-29-2012
    Location
    Scotland
    MS-Off Ver
    Excel 2010
    Posts
    84

    Re: Macro to change any occurence of a value in a workbook

    It's know how to do this myself but I've got users that arent great with excel. If I can set this up so all they have to do is hit a button it will be much easier for them.

  4. #4
    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,457

    Re: Macro to change any occurence of a value in a workbook

    OK ... they're not OK with Replace All but they are OK with enabling and running macros?

    Whatever:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-29-2012
    Location
    Scotland
    MS-Off Ver
    Excel 2010
    Posts
    84

    Re: Macro to change any occurence of a value in a workbook

    No need to give me attitude. I was only asking for your help!

  6. #6
    Registered User
    Join Date
    08-29-2012
    Location
    Scotland
    MS-Off Ver
    Excel 2010
    Posts
    84

    Re: Macro to change any occurence of a value in a workbook

    The users are forced to enable macros when they open the workbook. The macro will be set up by myself and assigned to a button. All they need to do is hit a button. I think this is far easier than replace all. The users I'm up against dont even know how to hide sheets. They are highly unlikely to know how to use the find and replace function.

  7. #7
    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,457

    Re: Macro to change any occurence of a value in a workbook

    It's know how to do this myself
    Not everyone would. I didn't know for sure until I checked it out.


    I was only asking for your help!
    Which I have given. Free of charge. Gratis.

    I'm not giving you attitude. I am giving you everything you asked for. By return. 8 minutes turn round on the first question; 13 minutes on the follow up.


    Your post has had 36 views to date. I'm the only one who has replied. What does that tell you?

    I simply asked a question based on your statement
    I've got users that arent great with excel.
    I think that, if anyone is "giving attitude", it might be you.


    Regards, TMS

  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,457

    Re: Macro to change any occurence of a value in a workbook

    You have given me background that I did not have when I asked the question. Had I known that, I wouldn't have asked it.

    In my own way, I was trying to save you the trouble of developing and implementing a code solution if it was not required/essential.

    If you already have code in place, in particular, code that mandates the enabling of macros, that is a different story.

    Regards, TMS

  9. #9
    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,457

    Re: Macro to change any occurence of a value in a workbook

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  10. #10
    Registered User
    Join Date
    08-29-2012
    Location
    Scotland
    MS-Off Ver
    Excel 2010
    Posts
    84

    Re: Macro to change any occurence of a value in a workbook

    I understand you dont know my background or my users background. So thats why I told you in my second post. To let you understand why I needed to do it this way.
    It's know how to do this myself but I've got users that arent great with excel. If I can set this up so all they have to do is hit a button it will be much easier for them.
    I'm grateful for your help but I to reply with
    Whatever:
    Is rude as far as I'm concerned
    Last edited by Nicola13; 11-30-2012 at 08:50 AM.

  11. #11
    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,457

    Re: Macro to change any occurence of a value in a workbook

    Quote Originally Posted by Nicola13 View Post
    I understand you dont know my background or my users background. So thats why I told you in my second post. To let you understand why I needed to do it this way.

    I'm grateful for your help but I to reply with

    Is rude as far as I'm concerned

    As I said, I didn't have that information when I asked the question. I was, therefore trying to be helpful. You see that all the time from me, and other responders. Some people are very grateful to have been offered an alternative approach which they may not have thought of. Perhaps you could consider providing a little bit more background in future questions? Just because a question is posed in the programming sub-forum, it does not necessarily mean that a VBA solution is the best one. If you had said, "I know how to do this manually but I need a macro solution because ...", I would not have trod that path, and I would probably not have upset you.

    As for "whatever", it was meant as "but, if that's what you want ..." (still bearing in mind that I was unaware of your macro mandating environment). Perhaps a poor choice but not meant to be rude.

    Anyway, you have your solution, and we have now spent more time discussing the niceties than actually producing that solution.

    If I have offended you, I apologise. It won't happen again.


    Regards, TMS

  12. #12
    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,457

    Re: Macro to change any occurence of a value in a workbook

    I note that at least one of our past encounters has not been so, well, what word would you use to describe it? Frosty?

    http://www.excelforum.com/excel-prog...nd-insert.html

    Yet this one didn't merit feedback or closure:

    http://www.excelforum.com/excel-prog...nt-to-vba.html


    Only 11 out of 24 threads started by you are marked Solved. Some don't even get a response to a question from someone who has been trying to help you; this from Dilipandey:

    http://www.excelforum.com/excel-form...workbooks.html


    Now that's what I call "rude".


    Regards, TMS

+ 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