+ Reply to Thread
Results 1 to 5 of 5

vba code to find text string in module and edit it

  1. #1
    Registered User
    Join Date
    10-25-2013
    Location
    canada
    MS-Off Ver
    Excel 2007
    Posts
    79

    vba code to find text string in module and edit it

    Hello,

    I have multiple workbooks that have this code attached

    Please Login or Register  to view this content.
    The width value is going to be changing by +/- 0.75 multiple times, I'm looking for a code that will locate that line in the code and add a multiple of 0.75 to the width value and modify the code

    I found this at http://www.cpearson.com/excel/vbe.aspx just not sure how to apply it to what I'm looking for.
    Please Login or Register  to view this content.
    thanks for any help!

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: vba code to find text string in module and edit it

    Hi,

    I think your life would be easier if you altered the code to simply read the value from a cell, defined name or document property. Then future changes would not require altering the code at all.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Registered User
    Join Date
    10-25-2013
    Location
    canada
    MS-Off Ver
    Excel 2007
    Posts
    79

    Re: vba code to find text string in module and edit it

    xlnitwit thanks for the reply.

    I like where you're going with this

    Could you elaborate with the defined name and document property options as I'm not sure how to make those work?

    Thanks

  4. #4
    Registered User
    Join Date
    01-22-2013
    Location
    Lowestoft, England
    MS-Off Ver
    2016
    Posts
    17

    Re: vba code to find text string in module and edit it

    Hi hopefulhart,

    What I would normally do is to create a module called Declares that is specifically for any Global values to be used throughout the rest of the code.

    For example -
    Please Login or Register  to view this content.
    By doing this, you will only need to change the value in your declares module. Any references to the defined item will use its current value.

    If I write a macro that says
    Please Login or Register  to view this content.
    , the message box would say 10.
    If I then change the value of FormBuffer in my Declares module to 15, and run the same macro, the message box would output 30.

    Note that it is safest if you do this with constants rather than variables where possible. If you have a named variable it should be declared in the macro that it is being used in.

  5. #5
    Registered User
    Join Date
    10-25-2013
    Location
    canada
    MS-Off Ver
    Excel 2007
    Posts
    79

    Re: vba code to find text string in module and edit it

    Hey stimulus, thanks for your reply

    sorry I am not very proficient in vba so your suggestion kind of went over my head.



    And xlnitwit,

    I was playing around with the custom document properties after your suggestion. I set up a new custom number doc prop but it rounded up my decimal number. How do I make it so that it will recognize decimal numbers?

    Never mind, just made the custom doc prop a string type

    Thanks again
    Last edited by hopefulhart; 07-25-2017 at 12:13 PM.

+ 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. Storing complex text string into variable. Text string contains html or xml code.
    By jakopak in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-20-2015, 04:54 AM
  2. Replies: 3
    Last Post: 08-07-2015, 09:18 PM
  3. Trying to find & copy text string from page source code
    By LightingPop in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-16-2015, 09:24 PM
  4. Checking string text (find it hard to code, please help)
    By Poloartists in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-13-2015, 05:21 PM
  5. [SOLVED] Find & Edit Formatting of text in string that includes line breaks
    By Jennasis in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-07-2014, 11:50 AM
  6. [SOLVED] Find partial text string within another text string return original text into cell.
    By mikey42979 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-17-2013, 02:58 PM
  7. how to access Sheet module, normal module, Worbook module to type code
    By alibaba in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-31-2009, 07:51 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