+ Reply to Thread
Results 1 to 11 of 11

Edit a cell's value from "01/01/2022" to "01/01/2023" without changing its ISTEXT status

  1. #1
    Forum Contributor
    Join Date
    08-04-2013
    Location
    Bucharest
    MS-Off Ver
    Office Professional Plus 2019
    Posts
    303

    Edit a cell's value from "01/01/2022" to "01/01/2023" without changing its ISTEXT status

    Hi, this is seemingly a very simple task but I can't seem to get around it.

    Keep in mind that the initial format of the date cells must remain the same.

    That is, for example, =ISTEXT(B1)=TRUE and ISNUMBER(B1)=FALSE. The format in the home tab should show "Date", as it is currently.

    For me, any attempt to transform 01/01/2022 (cell B1), into 01/01/2023, changes the formatting (the status of ISTEXT and ISNUMBER), which is what I'm trying to avoid.

    There might be some funky cell formatting going on that causes the issue, but I can't seem to put my finger on it. Thanks again for any help/advice.
    Attached Files Attached Files
    Last edited by bibu; 12-22-2022 at 01:27 PM.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,957

    Re: Edit a cell's value from "01/01/2022" to "01/01/2023" without changing its ISTEXT stat

    Without using macros, you can create a row for formulas

    =SUBSTITUTE(B1,"2022","2023")

    copied across to match your 'dates' - copy the formulas and pastespecial values over your dates.

    Otherwise, a macro is easy

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,791

    Re: Edit a cell's value from "01/01/2022" to "01/01/2023" without changing its ISTEXT stat

    Select all those cells on row 1, then CTRL-H to bring up the Find & Replace dialogue, and you want to change 22 to 23_plus some other character. If you make this the non-breaking space character (which has an ASCII code of 160) then it won't be seen. SO:

    Find What: 22

    Replace With: 23x

    where to get x you hold down the Alt key and type 0160 on the numeric keypad, and if you look carefully you will see a space after the 3 in the Replace With box.

    Then you can click on Replace all to make those changes.

    Hope this helps.

    Pete

  4. #4
    Forum Contributor
    Join Date
    08-04-2013
    Location
    Bucharest
    MS-Off Ver
    Office Professional Plus 2019
    Posts
    303

    Re: Edit a cell's value from "01/01/2022" to "01/01/2023" without changing its ISTEXT stat

    Thanks everyone.
    Tested both solutions and I'll have to give the edge to Bernie Deitrick for two reasons: 1 - Pete's solution seems to add a space at the end of each cell. 2 - With Pete's solution, DATEVALUE(B1) gives an error. I don't think it's related to the space at the end of the cell, because if I try to TRIM it it still won't work.

    Anyway, excellent work! Thanks a million, at least I've learned something useful after many hours of fruitless attempts.

  5. #5
    Forum Expert
    Join Date
    12-09-2014
    Location
    Trakai, Lithuania
    MS-Off Ver
    2016
    Posts
    1,296

    Re: Edit a cell's value from "01/01/2022" to "01/01/2023" without changing its ISTEXT stat

    Ctrl+h-->What find (2022)-->Replace with (2023)
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,957

    Re: Edit a cell's value from "01/01/2022" to "01/01/2023" without changing its ISTEXT stat

    Re: "I don't think it's related to the space at the end of the cell, because if I try to TRIM it it still won't work."

    If you add a non-breaking space, TRIM will not remove it - it only removes Character 32 spaces. You could, of course, use DATEVALUE(LEFT(cell, LEN(cell)-1))

  7. #7
    Forum Contributor
    Join Date
    08-04-2013
    Location
    Bucharest
    MS-Off Ver
    Office Professional Plus 2019
    Posts
    303

    Re: Edit a cell's value from "01/01/2022" to "01/01/2023" without changing its ISTEXT stat

    Quote Originally Posted by Bernie Deitrick View Post
    Re: "I don't think it's related to the space at the end of the cell, because if I try to TRIM it it still won't work."

    If you add a non-breaking space, TRIM will not remove it - it only removes Character 32 spaces. You could, of course, use DATEVALUE(LEFT(cell, LEN(cell)-1))
    Thanks for this clarification.
    By the way, I've tested the VBA solution and it doesn't seem to work. Did it work for you? I think you can't set the Text property of a cell. I think it's read-only.

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,117

    Re: Edit a cell's value from "01/01/2022" to "01/01/2023" without changing its ISTEXT stat

    Can I ask a stupid question? Why do you want to retain the date as TEXT, rather than as a real date?

    You're the ONLY person (that I recall) who wanted this outcome!!
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  9. #9
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,957

    Re: Edit a cell's value from "01/01/2022" to "01/01/2023" without changing its ISTEXT stat

    Quote Originally Posted by bibu View Post
    Thanks for this clarification.
    By the way, I've tested the VBA solution and it doesn't seem to work. Did it work for you? I think you can't set the Text property of a cell. I think it's read-only.
    You're correct - I should have used c.Value instead of the first c.Text.

    Sorry about that.

  10. #10
    Forum Contributor
    Join Date
    08-04-2013
    Location
    Bucharest
    MS-Off Ver
    Office Professional Plus 2019
    Posts
    303

    Re: Edit a cell's value from "01/01/2022" to "01/01/2023" without changing its ISTEXT stat

    Quote Originally Posted by Glenn Kennedy View Post
    Can I ask a stupid question? Why do you want to retain the date as TEXT, rather than as a real date?

    You're the ONLY person (that I recall) who wanted this outcome!!
    Yes, you most certainly can. I want to retain this weird format because there are macros that copy info from this file, into other files. The copying is done based on the selected period (the row with the dates that is the subject of this topic). So, since the macros have been "custom made" to work with the current date format, changing the format would mean that the macros will fail.
    So I'd rather keep it as it is.
    Also, I've done some digging because I was curious to know how did that row get formatted like this. It seems they were initially dates, but then the sheet contents were formatted as table (with the date row as header), and this changed its formatting.
    Last edited by bibu; 12-24-2022 at 01:29 AM.

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,117

    Re: Edit a cell's value from "01/01/2022" to "01/01/2023" without changing its ISTEXT stat

    That makes sense, sort of. It underlies my dislike of Excel Tables... which "know better than you" and insist that headers are Text.

+ 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: 07-21-2022, 04:38 PM
  2. Replies: 6
    Last Post: 12-15-2019, 12:16 PM
  3. Replies: 5
    Last Post: 02-05-2019, 12:03 AM
  4. Replies: 6
    Last Post: 07-16-2017, 09:06 AM
  5. [SOLVED] Column X-Ref list - Sheet1 Col A "pages", Col B:FL "Req" to Sheet2 ColA "req", ColB "page"
    By excel-card-pulled in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-07-2017, 09:30 AM
  6. Replies: 4
    Last Post: 11-17-2013, 12:05 PM
  7. [SOLVED] How to USE """"" cells count """"" change font color
    By austin123456 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 06:14 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