Excel and cell formatting to text - excel

I have a cell with the contents of 41316. I have it formatted as 20130211.
I need another cell to reference that value, but in the cell have it showing as 20130211 not 41316 formatted.
This maybe an easy one, but for some reason it has me running in circles.
Thanks in advance for all responses.

Excel by default copies the format from a cell formatted as a date to a cell which references it. It sounds in your case that Excel hasn't done that for you, so you just need to format the new cell with your special format : paintbrush tool or Edit..Copy, Edit..Past Special..Formats or Format..Number..Custom and select your format, which will be at the bottom of a long list.

If a string is ok instead of a number, you can decompose that date in parts and concatenate:
Being A1 the cell containing the value:
= Year(A1) & "/" & Month(A1) & "/" & Day(A1)
The "&" symbol concatenates text. The slashes are optional if you want them separated by slashes.

if your cell referencing 20130211 is 'A1' put =TEXT(A1,"####") in your calculation cell. If you do it this way then it will still read as a number and not a string

Related

create hyperlink using cell value and some additional text in excel

I have excel sheet containing column with values such as
BANDHANBNK
SRF
SRTRANSFIN
L&TFH
IBULHSGFIN
FEDERALBNK
PNB
PEL
VOLTAS
I want to create hyperlink for each of this, url can be created as
https://in.tradingview.com/chart/?symbol=NSE:ACC1!
so I need to concatenate
https://in.tradingview.com/chart/?symbol=NSE: + cell value + 1!
doing this manually is too much work, is there any simpler way to do this?
one more thing is if cell value contains & or - it should be converted to underscore.
Use following formula. Here simply concatenating cell value with URL then concatenate 1!. Use Hyperlink() formula to make hyperlink.
=HYPERLINK("https://in.tradingview.com/chart/?symbol=NSE:" & A1 & "1!",A1)
To replace & and - by underscore _ use below SUBSTITUTE() formula.
=SUBSTITUTE(SUBSTITUTE(A1,"&","_"),"-","_")
this worked for me.
=HYPERLINK("https://in.tradingview.com/chart/?symbol=NSE:" & SUBSTITUTE(SUBSTITUTE(E2,"&","_"),"-","_") & "1!",E2)

Accounting cell type changes when read/write - Excel VBA

I am reading some cells of type accounting into a Variant variable and then writing the variable in a new workbook. When I do this, the number formatting gets all mixed up.
I first read the cell from the first workbook with value 69,77 € and cell format Accounting:
Dim tiendas As Variant
x=.Cells(1,1)
Then I create a new workbook and write the content of the variable into a cell:
wb.Worksheets(1).Cells(1, 1) = x
If I don´t do anything else, the copied value looks like this 697.715 and has a cell format of Number.
Then I try changing the cell format before writing the value, i.e.:
wb.Worksheets(1).Range("A1:A1").Style = "Currency"
wb.Worksheets(1).Cells(1, 1) = x
As a result I get € 697.715,00 and cell type Custom.
I have tried inverting the order, i.e. first writing the value and then changing the style to "Currency". This results in exactly the same result.
I have also tried changing the format in the different way, specifically by using what appears in the custom formatting in Excel (and doubling the quotes inside the string):
wb.Worksheets(1).Range("A1:A1").NumberForma="_-* #.##0,00 €_-;-* #.##0,00 €_-;_-* "" - ""?? €_-;_-#_-"
wb.Worksheets(1).Cells(1, 1) = x
The result in this case is 697715,000 € and cell format Custom.
It seems that the original number format is not being read properly but I don´t know how to fix this.
Any ideas are very mucho welcome.
Thanks in advance!
NOTE: My number setting in Windows are "," as a decimal symbol and "." as thousands separator.

Change "XX:XX:00" to "00:XX:XX"

So I have this data directly copy/paste from iTunes :
Excel have "XX:XX:00" format which is "hh:mm:ss" but as you can imagine, it is more like "mm:ss:00". Musics are not hours long !
As it's not a direct cell format problem, I couldn't find easily the answer on internet. I need sometihng to put the 2 "00" at the start (in order to have "00:mm:ss")
EDIT : It was a cell format comprehension problem.
You can just divide the cell value to 60 like so
and then choose custom format for that cell like this
Format the cell with the time (C1) as "General". If it retains its value, like 11:42, then convert it with =TimeValue(C1) and format the cell as Custom mm:ss
If it changes to something like 0.4875 then convert it with =C1/60 and format the result as Custom mm:ss
This formula should work:
="00:" & MID(TEXT(A1,"h:mm:ss"),SEARCH(":",TEXT(A1,"h:mm:ss"))+1,3) & RIGHT(TEXT(A1,"h:mm:ss"),2)
The important element is to convert the time into a text string.
Change A1 to the first cell of Duration (Duree) & copy the formula downward
Then, you can copy the result and paste it as values
Edit: you can also use just the right function:
="00:"&RIGHT(TEXT(A1,"h:mm:ss"),LEN(TEXT(A1,"h:mm:ss"))-SEARCH(":",TEXT(A1,"h:mm:ss")))

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

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