Replace cell value with it's visible value - excel

I have a list, that Excel keeps formatting as a date. The cells show the following (so this is the "visible" value):
06-14
06-01
05-14
10-01
....
These are not to be dates. However, Excel keeps formatting them as such, so the formula bar for the first one shows 06/14/2020. I want the formula bar to show 06-14 (or, to be technical, this is okay too '06-14). I don't want a date in the Formula bar.
I've tried VBA, but none of these do it:
Cells(1,1).Value = Cells(1,1).Text
Cells(1,1).Value = Cells(1,1).Value
It keeps the date in the formula bar.
Changing the cell's format to say Text just puts the full date number in the cell, e.g. 44138.

You're close, just do:
Cells(1,1).Value = "'" & Cells(1,1).Text

Related

Excel Chart title will not accept a date concatonated to a string

I'm trying to include a date in my excel chart title by putting a formula inside the title formula box:
="Some text "&TEXT(NOW(),"mmm dd")
I've tried putting the date into a cell, and referencing the cell, but that doesn't work:
="Some text "&TEXT(Statistik!$H$26,"mmm dd")
Strangely, I can put a date into the chart title:
=Statistik!$H$26
But as soon as I add text ("eg "&), it gives me an error message that there is something wrong in the formula. If I paste the same formula into a cell, it works fine. =Concatonate doesn't work either.
All credit to Rory. Put the whole formula into a cell, then just refer to that cell.
Concatenation within the title cell of the excel chart does not work. The title cell needs to be a single reference to another cell, eg, =A1, in which any concatenation occurs, eg, ="Some text "&TEXT(Statistik!$H$26,"mmm dd").

how to find value of a non-blank cell

I have sheet of data in excel. In column BF, when I select the BF1 to BF7 it shows there are 3 counts however, I failed to determine what that value is or why excel is counting a seemingly blank cell, BF3. I tried to change color of font of cell BF3, and I used 2 formulas to test it, still I can't figure out what the cell value is.
First formula I used =isblank(BF3) and second formula I used =value(BF3) and still no luck. Clearly the cell is not blank but what is it ?
Give this a try:
=IF(ISBLANK(BF3),"Truly empty",IF(LEN(BF3)=0,"Null value","Character code: " & CODE(BF3)))
where Null value means that BF3 contains something like:
=""
or its equivalent.
(An alternative:)
=IF(ISBLANK(BF3),"Truly empty",IF(LEN(BF3)=0,"Null value","Character code: " & UNICODE(BF3)))
If it is some weird Unicode character.

How to convert the result (as displayed) in the cell to text in Excel

I have formatted a cell in Excel as Scientific with 1 decimal place then I inserted a number in it like (0.41). After pressing enter the result displayed is (4.1E-01). My aim is to put this result in a cell with text format so that when I double click the cell, I can copy/modify the text (4.1E-01) as I want.
I tried to format that cell as text but the result gets back to 0.41. I also tried to copy the cell and paste the value only using "Special Paste" into a text-formatted cell but the result keeps returning to 0.41. Do you have a suggestion on how to solve this issue?
Thanks in advance
This is a bit of a work around unless you want to use VBA. In an adjacent cell type this formula:
=TEXT(A1,"0.00E+00")
Now you can copy that cell and paste values only and get just the text:
2.22E+27
If your okay with VBA use this:
Range("A2").Value = Range("A1").Text

In Excel and VBA, how to set value of cell to the formulas result rather than the formula

I'm getting values from one sheet and placing them in another using a macro in Excel. I currently have this which works fine:
sheet.range("B2:B35").Value = "=IF(SUMPRODUCT(--(Raw!$B$11:$B$322=$A2),--(Raw!$D$11:$D$322=All!$B$2),Raw!$H$11:$H$322)<>0,SUMPRODUCT(--(Raw!$B$11:$B$322=$A2),--(Raw!$D$11:$D$322=All!$B$2),Raw!$H$11:$H$322),""-"")"
It, obviously, puts that entire formula as the value of the cell. What I'd like is it just to put the result of the formula into the cell. I've tried adding Evaluate() around the "IF..." part, but then the IF doesn't evaluate correctly (I just end up with "-" in each cell). Is this possible to do or do I have to have separate code to loop through and change the value to the value of the cell?
Use:
sheet.range("B2:B35").Formula = "Your formula here"
If that doesn't work you may have to change the formatting (do this first):
sheet.range("B2:B35").NumberFormat = "General"
Edit:
A solution turned out to be addition of the following line after the OP's code:
sheet.range("B2:B35").value = sheet.range("B2:B35").value

Concatenating date with a string in Excel

I have two cells in Excel. one has a string and the other one has a date. in the third cell I want to put the date and the string together. For example:
A1 = "This "
A2 = "03/03/1982"
I want A3 to be:
This 03/03/1982
when I try to put this in the A3 formula: = A1 & A2 it returns some funny numerical value for the date and does not give me the literal date.
Don't know if it's the best way but I'd do this:
=A1 & TEXT(A2,"mm/dd/yyyy")
That should format your date into your desired string.
Edit: That funny number you saw is the number of days between December 31st 1899 and your date. That's how Excel stores dates.
This is the numerical representation of the date. The thing you get when referring to dates from formulas like that.
You'll have to do:
= A1 & TEXT(A2, "mm/dd/yyyy")
The biggest problem here is that the format specifier is locale-dependent. It will not work/produce not what expected if the file is opened with a differently localized Excel.
Now, you could have a user-defined function:
public function AsDisplayed(byval c as range) as string
AsDisplayed = c.Text
end function
and then
= A1 & AsDisplayed(A2)
But then there's a bug (feature?) in Excel because of which the .Text property is suddenly not available during certain stages of the computation cycle, and your formulas display #VALUE instead of what they should.
That is, it's bad either way.
Another approach
=CONCATENATE("Age as of ", TEXT(TODAY(),"dd-mmm-yyyy"))
This will return
Age as of 06-Aug-2013
Thanks for the solution !
It works, but in a french Excel environment, you should apply something like
TEXTE(F2;"jj/mm/aaaa")
to get the date preserved as it is displayed in F2 cell, after concatenation.
Best Regards
You can do it this simple way :
A1 = Mahi
A2 = NULL(blank)
Select A2 Right click on cell --> Format cells --> change to TEXT
Then put the date in A2 (A2 =31/07/1990)
Then concatenate it will work. No need of any formulae.
=CONCATENATE(A1,A2)
mahi31/07/1990
(This works on the empty cells ie.,Before entering the DATE value to cell you need to make it as TEXT).
I found that for this situation, the simplest solution is to define a Custom number format for the cell containing the date. The format in this case should be:
"This:" mm/dd/yyyy
To set this format:
Right click on the cell
Select Format Cell
Select Number tab (should be displayed by default)
Pick Custom from the Category list
Specify the format in the "Type" field
Press OK
Note: If you really want the preceding text to be picked from a cell, this solution will not work as described.

Resources