+ Reply to Thread
Results 1 to 4 of 4

Please Help: Formula to replace a character in cell with VBA

  1. #1
    Registered User
    Join Date
    03-17-2016
    Location
    SA
    MS-Off Ver
    2013
    Posts
    4

    Question Please Help: Formula to replace a character in cell with VBA

    Hi

    I please need help with the following issue I am experiencing

    I want to replace a "." character in the value of the cell to "-" using VBA code
    I currently have the following code

    Sub ReplaceInSelection()

    Selection.Find(What:=".", After:=ActiveCell, LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate
    Selection.Replace What:=".", Replacement:="-", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False

    End Sub

    Will this work and how do I apply/call it on a cell value?

    Please advise me on this
    Thank you

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,578

    Re: Please Help: Formula to replace a character in cell with VBA

    Yes, that code will change all "." in range. After placing the code into a VBA module, just manually select the region you want to change and run the macro. Does that work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Please Help: Formula to replace a character in cell with VBA

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    03-17-2016
    Location
    SA
    MS-Off Ver
    2013
    Posts
    4

    Re: Please Help: Formula to replace a character in cell with VBA

    Yes thanks that worked!

+ 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. How to replace the character in one cell with the value in another column
    By bayala87 in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 09-18-2015, 02:15 PM
  2. Search and replace character with cell value
    By rfcapinto in forum Excel General
    Replies: 2
    Last Post: 03-24-2014, 05:31 PM
  3. How to replace special character (square box) in cell
    By anilk.zee in forum Access Programming / VBA / Macros
    Replies: 2
    Last Post: 05-21-2012, 03:17 PM
  4. Find and replace a character with another cell contents
    By tcapewell in forum Excel General
    Replies: 4
    Last Post: 07-12-2010, 10:23 AM
  5. replace first character of cell content
    By Armitage2k in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-26-2009, 11:33 AM
  6. Macro to replace a character in a cell
    By redjay in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-17-2009, 12:27 PM
  7. Find 1 character and replace entire cell
    By s2nguyen in forum Excel General
    Replies: 2
    Last Post: 11-07-2008, 12:44 PM

Tags for this Thread

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