I'm fairly new to Excel and need some assistance. I have a Column that has a list of files that look like:
12345_v1.0_TEST_Name [12345]_01.01.2022.html
45321_v55.9_Some Name Here [64398]_07.15.2018.html
56871_v14.2_Test[64398]_10.30.2019.html
Each file name can be different depending on what output is provided to me.
Note: There are other random files in the same format, however where it says Test_Name there could be an underscore and sometimes no underscore. Would like that to be ignored in the formula or vba. Files also can change but will be in the same format.
I need some help with a formula or vba that splits the underscores and outputs the data into their own cells:
Column C 12345
Column D v1.0
Column E TEST_Name [12345]
Column F 01.01.2022
Column G .html
Since there can be different file extensions however the format remains same, hence the above formula which i provided has been amended with some few tweaks so that it works for any file extensions,
FORMULA IN CELL C1
=IF(LEN($B1)-LEN(SUBSTITUTE($B1,"_",""))+1>4,
TRIM(MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($B1,"."&TRIM(RIGHT(SUBSTITUTE(
SUBSTITUTE($B1,"."," ",LEN($B1)-LEN(SUBSTITUTE($B1,".","")))," ",REPT(" ",200)),100)),"_"&"."&
TRIM(RIGHT(SUBSTITUTE(SUBSTITUTE($B1,"."," ",LEN($B1)-LEN(SUBSTITUTE($B1,".","")))," ",
REPT(" ",200)),100))),"_"," ",3),"_",REPT(" ",100)),COLUMN(A1)*99-98,100)),
TRIM(MID(SUBSTITUTE(SUBSTITUTE($B1,"."&TRIM(RIGHT(SUBSTITUTE(SUBSTITUTE(
$B1,"."," ",LEN($B1)-LEN(SUBSTITUTE($B1,".","")))," ",REPT(" ",200)),100)),"_"&"."&
TRIM(RIGHT(SUBSTITUTE(SUBSTITUTE($B1,"."," ",LEN($B1)-LEN(SUBSTITUTE($B1,".","")))," ",
REPT(" ",200)),100))),"_",REPT(" ",100)),COLUMN(A1)*99-98,100)))
FILL DOWN & FILL ACROSS!!!
There are other random files in the same format.....Files also can change but will be in the same format.
So, assuming the files indeed will be in the same format, we can brake this query down into the following requirements:
Change the 1st and 2nd occurence and the very last of the underscore into anything to split on;
Change the dot before the file-extension into anything to split on under the assumption we don't know if this would be '.html' or any other extension.
Since you have Microsoft365 we can use dynamic arrays and some basic functions to retrieve what you want:
=LET(X,SEARCH("_??.??.????.",A1),Y,"</s><s>",TRANSPOSE(FILTERXML("<t><s>"&SUBSTITUTE(SUBSTITUTE(REPLACE(A1,X,12,Y&MID(A1,X+1,10)&Y),"_",Y,2),"_",Y,1)&"</s></t>","//s")))
To break this down a little bit:
SEARCH("_??.??.????.",A1) - This part will make sure that we find the position of the very last underscore upto the dot before the file extension assuming you don't have any other date in your filenames in this specific format;
SUBSTITUTE() - We can use this formula to specifically change the 1st and 2nd instances of the underscore to anything we can split on;
FILTERXML() - You may notice we used valid xml start/end-tags to split our data using this function.
TRANSPOSE() - This last function will now spill the returned array over the columns instead of rows.
Without LET():
=TRANSPOSE(FILTERXML("<t><s>"&SUBSTITUTE(SUBSTITUTE(REPLACE(A1,SEARCH("_??.??.????.",A1),12,"</s><s>"&MID(A1,SEARCH("_??.??.????.",A1)+1,10)&"</s><s>"),"_","</s><s>",2),"_","</s><s>",1)&"</s></t>","//s"))
Is this what you are trying to achieve, although there might be more eloquent way to use a formula, and solve this, however you may try using this as well,
FORMULA USED IN CELL C1
=IF(LEN($B2)-LEN(SUBSTITUTE($B2,"_",""))+1>4,TRIM(MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($B2,".html","_.html"),"_"," ",3),"_",REPT(" ",100)),COLUMN(A2)*99-98,100)),TRIM(MID(SUBSTITUTE(SUBSTITUTE($B2,".html","_.html"),"_",REPT(" ",100)),COLUMN(A2)*99-98,100)))
Fill Down & Fill Across !
I want to split cells in excel. I have one column A with many rows and between the text there are 2 spaces, For example
2 GABRIE 205.10 V3361 40.00
3 THOMAS 230.80 A1003 20.00
.
.
must be split into 5 columns.
UPDATE
After using =CODE(A2) to test on the file you provided, those so called "spaces" are actually char(160). Basically they are Non-breaking spaces that is common character entities in HTML used to make two words stick together at the end of a line. If you are pasting a string into Excel from an HTML-based source, it is possible you will run into this issue.
Solution
Apply this formula =SUBSTITUTE(A2,CHAR(160)," ") to your cells and modify accordingly. You will get the "same data" but different result. See image for reference.
After applying the formula, copy the result to a text editor(Notepad) or whatever you comfortable with. The copy back the result in Notepad to excel, it will auto split into 5 columns. (Actually 6 if the space is considered).
I have rows on my excel that has following values below.
Brandon (39042, 39047),Pearl (39208),Fondren and Belhaven,North Jackson (39206,39211),Byram (39272),South Jackson (39212, (39204),Clinton (39056),Madison (39110),Ridgeland (39157),West Jackson (39209)
What I'm trying to accomplish is change the comma that separate each values into semi-colon, wherein those comma within parentheses ie. (39042, 39047) shouldn't be affected.
Already tried googling but cannot find anything.
Assuming your data is in A1
=SUBSTITUTE(A1, ")," , ");" )
I put spaces in for easier reading. Copy the formula down as far as you can go.
Alternatively use the built in search and replace function of excel. CNTRL + H.
I´ve this simple text inside a cell - this is an example of many with the same issue - and I need to put that into columns, delimited by spaces.
When I do that, the function just do the work with the first sentence, finishing in "deck", and stops there so I´m loosing half of my information or more If I´ve more lines.
I can´t understand why it´s happening, and I worked for hours on a macro that depends on this information as I wrongly assumed this would be plain easy.
($94.52) Hold revenue. Need to set up deck.
($10.89) Hold revenue. Need to contact purchaser.
Thanks for your help!
Ok I got the answer so I´ll post it myself.
I need to separate based on spaces and carriage returns, but I was just trying with spaces thinking there was no way to add carriage returns as a separator. I was wrong.
When you select the function, you´ve a field called "other". There you need to add "Control + J", which is the shortcut for carriage returns.
With that fix, the result is as expected.
Assuming your column is A and starts in row 1, create a second column with the following formula in B1:
=SUBSTITUTE(A1,CHAR(10)," ")
Copy down the entire B column. Copy and paste this column as values.
Now use the Text to Columns functionality, but use space as the delimiter.
I am using a formula to sum a certain word from a filtered list on another sheet. I have the following formula and example of the data I am looking for:
=SUMPRODUCT((SUBTOTAL(3,OFFSET('Data'!R1,1,0)))*('Outage'!R:R="Birds"))
So what this formula does is go to the 'Outage' sheet and read a filtered Column R and looks for rows that have the word "Birds" and sums the occurrence and finally outputs it to a cell.
The problem I am having is that the data in Column R can have extra spaces in between. So for example, "Birds" would be " Birds" or "[newline]Birds". I am getting the data from a HTML page so there can be extra spaces.
When Excel executes SUMPRODUCT, "[newline]Birds" does not equal "Birds" so it doesn't increment my count, which I need it to do. I have tried:
=SUMPRODUCT((SUBTOTAL(3,OFFSET('Data'!R1,1,0)))*(TRIM('Outage Data'!R:R)="Birds"))
But it is not working.
Any help would be appreciated. Thanks!
TRIM will only remove whitespace at the start and end of the cell data. You need to use CLEAN to remove non-printable characters.
It may be that you need to use both if your data has newline and spaces.
Office Ref - CLEAN
So in theory the following should work for you:
=SUMPRODUCT((SUBTOTAL(3,OFFSET('Data'!R1,1,0)))*(TRIM(CLEAN('Outage Data'!R:R))="Birds"))