+ Reply to Thread
Results 1 to 10 of 10

Macro to edit variable text in a specific cell

  1. #1
    Registered User
    Join Date
    05-08-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    13

    Macro to edit variable text in a specific cell

    I have several clients who, for whatever reason insist on entering their business name twice in a specific cell, which causes havoc with my workbook.
    EG.
    The text appears in the cell as Smiths Hardware, carriage return, Smiths Hardware.
    Is there any way I can run a simple macro which will edit this text to simply read Smiths Hardware?

    I have tried numerous methods and I'm having less than satisfactory results.

    I would like the macro to work on the same specific cell, regardless of the clients duplicated name.

    Any help would be greatly appreciated.

  2. #2
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Macro to edit variable text in a specific cell

    @westic

    please try

    Please Login or Register  to view this content.
    If you like my contribution click the star icon!

  3. #3
    Registered User
    Join Date
    05-08-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Macro to edit variable text in a specific cell

    I ran your code and it throws up a type mismatch error?
    The duplicated names are in column AD and Row 1 is the header column as you correctly surmised.
    The sheet name is a variable, however it is always sheet 1, regardless of the tab name.

    Thanks for help.

  4. #4
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Macro to edit variable text in a specific cell

    From your post I cannot tell where the type mismatch occurs.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-08-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Macro to edit variable text in a specific cell

    Please Login or Register  to view this content.
    The preceding line is highlighted by debugger.

  6. #6
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Macro to edit variable text in a specific cell

    westic,

    Sorry but I fail to see anything wrong on that line. Unless, the previous statement fails, i.e. selecting the worksheet. Please replace the 1 with the name of the worksheet between quotes or the variable holding the worksheet name

  7. #7
    Registered User
    Join Date
    09-27-2011
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    86

    Re: Macro to edit variable text in a specific cell

    Hi OllieB,

    Use with the formula option: -
    =LEFT(A1,(LEN(A1)-FIND(CHAR(10),A1)))

    change the reference cell A1 as per your requirement

    Regards,
    loki

  8. #8
    Registered User
    Join Date
    05-08-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Macro to edit variable text in a specific cell

    Thanks again for you help OllieB.
    The worksheet name varies every time I load an order, which is why I have to refer to it by it's logical number. The code would only work for one specific customer if I use the sheet name.
    The answer is probably staring me in the face.

  9. #9
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Macro to edit variable text in a specific cell

    Hi Westic,

    If you don't know the name you will need to specify the worksheet number.

  10. #10
    Registered User
    Join Date
    05-08-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Macro to edit variable text in a specific cell

    Sheet1.
    I have addressed the sheet by it's number and have the same error.
    Getting late here so I'll hit the sack and maybe the solution will come to me.
    Thanks again.
    Cheers.

+ 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. Macro to copy specific line from text file and paste into specific cell in excel
    By keeneye in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-05-2013, 10:35 AM
  2. [SOLVED] Macro to search rows for specific text within a cell then cut cell to specified location
    By jonathanpotts90 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-25-2012, 06:18 AM
  3. macro - search within a cell and edit the text string
    By filo.soph in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-21-2011, 09:19 AM
  4. Macro for copying specific text from a cell
    By mvel_sky in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-29-2010, 02:47 AM
  5. [SOLVED] How to Create a Macro to Edit a Variable Amount of Information
    By Matt in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 08-12-2006, 05:10 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