+ Reply to Thread
Results 1 to 2 of 2

Need Help for Run macro

Hybrid View

  1. #1
    Registered User
    Join Date
    08-19-2012
    Location
    india
    MS-Off Ver
    Excel 2003
    Posts
    1

    Need Help for Run macro

    I need replace text between {} with "class"

    Examle -- {aaaaaaaaaa} 4-6pm and {bbbbbbbbbb} 6-8 pm

    i need to replace above value class 4-6pm and class 6-8pm

    Sample file is alos attached.


    Here is my macro:-

    Option Explicit
    Sub BoldTextString()
    Dim s As String
    Dim r As Range, c As Range
    Dim re As Object, mc As Object, m As Object
    Dim i As Long

    Set r = Selection
    Set re = CreateObject("vbscript.regexp")
    re.Global = True
    re.ignorecase = True

    For Each c In r
    re.Pattern = "{[\s\S]+?(?=})"
    Set mc = re.Execute(c.Text)
    re.Pattern = "{|}"
    c.Value = re.Replace(c.Text, "")
    i = 0
    For Each m In mc
    With c.Characters(m.firstindex + 1 - 3 * i, _
    m.Length - 1)
    .insert = ("class")
    .Font.Bold = True
    .Font.Underline = True
    .Font.Size = 11

    End With

    i = i + 1
    Next m
    Next c
    End Sub



    Thanks in advance.


    REgards
    Sourabh
    Attached Files Attached Files

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Need Help for Run macro

    Welcome to the Forum, unfortunately:

    1) Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title go to your first post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    2) Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

+ 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. Using a macro on workbook1 to create a button in wb2 and assigning macro "wb2!macro"
    By penfold1992 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-13-2014, 11:39 AM
  2. [SOLVED] Macro to show Which macro didnt work in a nested macro
    By akhileshgs in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-10-2013, 03:21 AM
  3. Perform macro "on open" specific file- store macro in Personal Macro Workbook?
    By thompssc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-17-2012, 12:38 PM
  4. lookup macro, solver macro, realtime macro
    By xelhelp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-02-2011, 06:14 PM
  5. Cannot find macro error when running a macro from a macro in a diffrent workbook.
    By Acrobatic82 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-05-2010, 09:22 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