+ Reply to Thread
Results 1 to 18 of 18

Need macro to find and replace

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

    Need macro to find and replace

    Hi,

    I have to clean data like as mentioned below on regular basis.I need macro to find and replace the values quickly.

    Employee Count
    1000-9999
    1000-9999
    1000-9999
    1000-9999
    1000-9999
    100+
    100,

    I have to keep all the data after hyphen that is 9999
    and remove trailing + and commas all in one function.
    The macro should help me to clean these three requirements.
    Thanks,

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Need macro to find and replace

    Please Login or Register  to view this content.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Need macro to find and replace

    Please Login or Register  to view this content.

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

    Re: Need macro to find and replace

    Hi Can you please include two more criteria to the code.

    Sub RunMe()
    Dim ws As Worksheet: Set ws = Sheets("Sheet1")
    Dim rCell As Range
    Dim mySplit

    For Each rCell In ws.UsedRange.SpecialCells(xlCellTypeConstants)
    If Not InStr(1, rCell.Value, "-") = 0 Then
    mySplit = Split(rCell.Value, "-")
    rCell.Value = mySplit(UBound(mySplit))
    Else
    If Right(rCell.Value, 1) = "+" Or Right(rCell.Value, 1) = "," Then
    rCell.Value = Mid(rCell.Value, 1, rCell.Characters.Count - 1)
    End If
    End If
    Next rCell

    End Sub
    Employee Count
    100 to 200
    100>500

    Thanks

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

    Re: Need macro to find and replace

    Hi,

    Thanks for help.Actually I need to add two more criteria to the above conditions.
    Employee Count
    100 to 200
    100>500

    I have to keep all the data after to that is 200
    I have to keep all the data after > that is 500

    Thanks

  6. #6
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Need macro to find and replace

    I have no idea what you mean

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

    Re: Need macro to find and replace

    Hi,

    I have to clean data like as mentioned below on regular basis.I need macro to find and replace the values quickly.

    Employee Count
    1000-9999
    1000-9999
    1000-9999
    1000-9999
    1000-9999
    100 to 200
    100>200
    100+
    100,

    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
    and remove trailing + and commas all in one function.
    The macro should help me to clean these requirements.
    Thanks,

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,560

    Re: Need macro to find and replace

    Try
    Please Login or Register  to view this content.

  9. #9
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Need macro to find and replace

    Here you go

    Please Login or Register  to view this content.

  10. #10
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Need macro to find and replace

    Here's another
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

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

    Re: Need macro to find and replace

    Hi,

    I have to create the Data check bar in tool bar section and under Data check bar I need to create ribbon called find and replace for this code.

    Please provide step by step instruction design this tool.
    Please Login or Register  to view this content.
    Last edited by narendrabr; 01-03-2014 at 08:11 AM.

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

    Re: Need macro to find and replace

    Hi,

    I have to create the Data check Tab and under Data check bar I need to create ribbon button called find and replace for this code.

    Please provide step by step instruction design this tool.
    Please Login or Register  to view this content.
    Last edited by narendrabr; 01-03-2014 at 08:11 AM.

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

    Re: Need macro to find and replace

    Hi,

    I have to clean data like as mentioned below on regular basis.I need macro to find and replace the values quickly.

    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,

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

    Re: Need macro to find and replace

    I have to add one more criteria to this code.I have to retain
    Only 1000 if the data has over 100 or any.
    Please Login or Register  to view this content.

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

    Re: Need macro to find and replace

    Please find attached sheet.
    Attached Files Attached Files

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

    Re: Need macro to find and replace

    Hi,

    I have to format data data like as mentioned below on regular basis.I need macro to find and replace the values quickly.

    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 data after Over
    and remove trailing + and commas all in one function.
    The macro should help me to clean these requirements.
    Thanks,

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

    Re: Need macro to find and replace

    Hi,

    I have to format data data like as mentioned below on regular basis.I need macro to find and replace the values quickly.

    Employee Count
    1000-9999
    1000-9999
    1000-9999
    1000-9999
    1000-9999
    100 to 200
    100>200
    100+
    100,

    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
    and remove trailing + and commas all in one function.
    The macro should help me to clean these requirements.
    Thanks,

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

    Re: Macro to find and replace

    Hi Basically if I run a macro it should quickly remove any unwanted data like shown below
    The macro can be runned to any column not just the column A.
    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 all the data after Over
    and remove trailing + and commas all in one function.
    The macro should help me to clean these requirements.
    Let me know if you need any clarification

    Thanks!

+ 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. Replies: 2
    Last Post: 06-12-2013, 03:48 PM
  2. [SOLVED] Use Find and Replace in a macro
    By bigfishprf in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-21-2013, 12:52 PM
  3. Find/Replace Macro Using Replace Table
    By LampCommandr in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-24-2011, 11:00 AM
  4. Optimizing Excel macro to find/replace with the list of data contained in the macro
    By Iceyburnz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-17-2008, 08:41 PM
  5. Using Find and Replace to replace " in a macro
    By snail30152 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-13-2006, 06:58 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