Closed Thread
Results 1 to 5 of 5

Need help to modify the macro code

Hybrid View

narendrabr Need help to modify the macro... 01-14-2014, 09:45 AM
alansidman Re: Need help to modify the... 01-14-2014, 11:32 AM
narendrabr Re: Need help to modify the... 01-14-2014, 12:16 PM
AB33 Re: Need help to modify the... 01-14-2014, 12:06 PM
alansidman Re: Need help to modify the... 01-14-2014, 03:40 PM
  1. #1
    Forum Contributor
    Join Date
    08-12-2012
    Location
    mysore
    MS-Off Ver
    Excel 2007
    Posts
    212

    Need help to modify the macro code

    Sub SplitStuff()
    Dim cel As Range
        For Each cel In Range(("A2"), Range("a2").End(xlDown))
            On Error Resume Next
            cel.Value = Trim(Split(cel.Value, "-")(1))
            On Error GoTo 0
        Next cel
    
        For Each cel In Range(("A2"), Range("a2").End(xlDown))
            On Error Resume Next
            cel.Value = Trim(Split(cel.Value, "to")(1))
        Next cel
        On Error GoTo 0
    
        For Each cel In Range(("A2"), Range("a2").End(xlDown))
            On Error Resume Next
            cel.Value = Trim(Split(cel.Value, ">")(1))
        Next cel
        On Error GoTo 0
    
        Columns("A:A").Replace What:="+", Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, _
                MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
        Columns("A:A").Replace What:=",", Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, _
                MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
    
    End Sub
    Hi,

    I have to format data like as mentioned below on regular basis.I need macro to find and replace the values quickly.
    Please help to modify the code.
    Employee Count
    1000-9999
    1000-9999
    1000-9999
    1000-9999
    1000-9999
    100 to 200
    100>200
    100+
    100,
    Over 1000
    I have to keep all the data after hyphen that is 9999
    I have to keep all the data after 'to' that is 200
    I have to keep all the data after '>' that is 200
    I have to keep the data after 'Over'
    and remove trailing + and commas all in one function.
    The macro should help me to clean these requirements.
    Thanks,

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,755

    Re: Need help to modify the macro code

    Your explanation of what you have and what you want is not clear. Suggest you upload a sample spreadsheet.

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    08-12-2012
    Location
    mysore
    MS-Off Ver
    Excel 2007
    Posts
    212

    Re: Need help to modify the macro code

    Please find the sheet.

    Thanks!
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Need help to modify the macro code


  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,755

    Re: Need help to modify the macro code

    Welcome to the Forum, unfortunately:

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread.

    Thread Closed.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Help to modify vba code
    By christopherjward in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-29-2013, 06:56 PM
  2. How to modify Worksheet_Change Macro VBA code from Range to Cell
    By AGCSC1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-25-2013, 04:23 PM
  3. How to modify VB code?
    By sem in forum Excel General
    Replies: 3
    Last Post: 08-07-2012, 05:29 AM
  4. [SOLVED] Array Formula vs vBa code - How To Modify My Messy Code To One Of Those
    By ScotyB in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-20-2012, 12:04 AM
  5. Modify Code
    By Bob@Sun in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-29-2010, 06:25 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