+ Reply to Thread
Results 1 to 7 of 7

VBA Code Modification

  1. #1
    Registered User
    Join Date
    02-12-2011
    Location
    London
    MS-Off Ver
    Excel MAC 2011
    Posts
    12

    VBA Code Modification

    Hello there,
    I have some code - originally kindly given to me from someone here a long time ago.
    I need to modify it, I am not very good with VB and have been trying last 2 days without success.

    Currently this code searches for text which begins with a < and ends with >

    I know it is easy to adjust a single start and end character but I wish to search for more - e.g.. start with <span & ends with span>
    I really cannot figure this out if I enter these parameters I get no response back, any help gratefully received.
    Thanks

    EXISTING CODE

    Please Login or Register  to view this content.
    NEW CODE
    Please Login or Register  to view this content.
    Last edited by guapo; 06-12-2014 at 06:24 AM.

  2. #2
    Registered User
    Join Date
    02-12-2011
    Location
    London
    MS-Off Ver
    Excel MAC 2011
    Posts
    12

    Re: VBA Code Modification

    Hi
    I believe I have modified the post with the required [code] tags now
    Hopefully someone can help me resolve this problem now
    Many Thanks
    Last edited by guapo; 06-12-2014 at 06:50 AM.

  3. #3
    Valued Forum Contributor Miroslav R.'s Avatar
    Join Date
    05-16-2013
    Location
    NMnV, Slovakia
    MS-Off Ver
    Excel 2007
    Posts
    479

    Re: VBA Code Modification

    Hi there,
    look at this:
    Please Login or Register  to view this content.
    You test 1 character agains 5 characters:
    F.e.: if Your range value is '<span>' then the condition Mid("<span>", n, 1) will never be met, since '<' will never be equal to '<span'.
    You have to change the lenght of string in MID, but then You also have to change the rest of IF-END IF according to what You want to extract.

    Hope it helps
    Regards
    Miroslav R.

    (If You like my solutions, feel free to add reputation.)

  4. #4
    Registered User
    Join Date
    02-12-2011
    Location
    London
    MS-Off Ver
    Excel MAC 2011
    Posts
    12

    Re: VBA Code Modification

    Ok I'm not totally with you here, but I will give it a go.
    i realised I needed to change something else but was not sure what to change.
    So to change the length of sting in MID is that by substituting the 1 for a five? eg. Mid(rng, n, 5)
    And then I assume changing everything further to 5? as below code.

    Ok I tried it and it sort of worked, well better than any previous attempts, the text is coming out sort of garbled now, the start and finish is correct though.
    Will look to see if I missed something else?
    Thanks for your help


    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor Miroslav R.'s Avatar
    Join Date
    05-16-2013
    Location
    NMnV, Slovakia
    MS-Off Ver
    Excel 2007
    Posts
    479

    Re: VBA Code Modification

    hm...
    what should Your function actually do?
    When the cell value start with '<span' and end with 'span>' then it should return original cell value?

  6. #6
    Registered User
    Join Date
    02-12-2011
    Location
    London
    MS-Off Ver
    Excel MAC 2011
    Posts
    12

    Re: VBA Code Modification

    It should find any text within a cell that starts with <span & ends with span>

    for example text in cell abcdefgh<span>123456789<span>abcdefgh
    Then using this function along with =TrimCell I should get a result of <span>123456789<span>
    The result I am getting with my code above is something starting an finishing with <span & span> which is great, but I seem to have multiple instances of the text in-between

  7. #7
    Registered User
    Join Date
    02-12-2011
    Location
    London
    MS-Off Ver
    Excel MAC 2011
    Posts
    12

    Re: VBA Code Modification

    Ok I think i hav cracked it now - not entirely sure how i got there, but of trial and error!

    Thank you very much for your help on this really saved me a lot of time :-)

  8. #8
    Valued Forum Contributor Miroslav R.'s Avatar
    Join Date
    05-16-2013
    Location
    NMnV, Slovakia
    MS-Off Ver
    Excel 2007
    Posts
    479

    Re: VBA Code Modification

    You are welcome...

+ 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. help with Code modification
    By onp in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-16-2014, 07:00 PM
  2. Little modification in code
    By mukeshbaviskar in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-18-2013, 02:15 PM
  3. code modification
    By tofimoon4 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-12-2010, 06:26 AM
  4. Modification to existing Code
    By Jim May in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-04-2006, 12:55 PM
  5. modification for the code
    By srinivasan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-20-2005, 11:05 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