+ Reply to Thread
Results 1 to 9 of 9

How to check for a blank space and decide to add or not? Interesting

  1. #1
    Registered User
    Join Date
    11-02-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    81

    How to check for a blank space and decide to add or not? Interesting

    Hi, I have an interesting question and is useful to my case.

    When a file is open, if cell A1 has a text "Hello there", then I want to make this cell add a blank space as "Hello there ". Let's save this file and close. So now if I re-open it, I want cell A1 to remove the added blank space and revert to be "Hello there". This take turns to change back and forward.

    Any idea with simple Excel function, or does this have to be done with VBA?

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

    Re: How to check for a blank space and decide to add or not? Interesting

    You couldn't do it with a formula, as a formula returns a result to the cell it is in (it can't "push" a value to another cell). Thus, A1 would have to contain the formula and you would need some other cell to indicate whether the space should be there or not (e.g. by counting the number of times the file has been saved and then determining if that is an odd or even number).

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    11-02-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    81

    Re: How to check for a blank space and decide to add or not? Interesting

    Hi Pete, it's absolutely right to have a formula in cell A1, so that the formula can make the value be dynamic with a blank space adding or not adding. Some formula in cell A1 like:

    ="Hello there" & xxx

    Your ideas is that xxx. can be made to be the number of times the file has been saved. I'm not sure if this can be done via some Excel function, or this has to go with the VBA?

  4. #4
    Registered User
    Join Date
    11-02-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    81

    Re: How to check for a blank space and decide to add or not? Interesting

    Hi Pete, it's absolutely right to have a formula in cell A1, so that the formula can make the value be dynamic with a blank space adding or not adding. Some formula in cell A1 like:

    ="Hello there" & xxx

    Your ideas is that xxx can be made to be the number of times the file has been saved. I'm not sure if this can be done via some Excel function, or this has to go with the VBA?

  5. #5
    Registered User
    Join Date
    11-02-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    81

    Re: How to check for a blank space and decide to add or not? Interesting

    Is there a way to do this? Please

  6. #6
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: How to check for a blank space and decide to add or not? Interesting

    As already said by PeterUK.

    In Excel it's only possible, if you refer to another cell.

    Probably it can be done with VBA.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  7. #7
    Registered User
    Join Date
    11-02-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    81

    Re: How to check for a blank space and decide to add or not? Interesting

    Quote Originally Posted by oeldere View Post
    As already said by PeterUK.

    In Excel it's only possible, if you refer to another cell.

    Probably it can be done with VBA.
    Hi oeldere, how to do this by referring to another cell?

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

    Re: How to check for a blank space and decide to add or not? Interesting

    You could have a formula like this in A1:

    ="Hello there" & IF(MOD(X1,2)=0," ","")

    where X1 would contain a count of the number of times the file was saved, and if that was an even number then a space would be added. However, a formula couldn't get that count to increment automatically when a file was saved - you would need VBA for that.

    Hope this helps.

    Pete

  9. #9
    Registered User
    Join Date
    11-02-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    81

    Re: How to check for a blank space and decide to add or not? Interesting

    Thanks for your help, Pete. VBA must be needed

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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