auto-fill one column without dragging - Google sheet - google-sheets

How can I fill column A from A1 - A5000 with the same text string "ABC DEF" without dragging it in Google Sheets?
E.g.:
A1 ABC DEF
A2 ABC DEF
...
A5000 ABC DEF

You could try in A1
=Arrayformula(if(row(A1:A5000), "ABC DEF",))
and see if that helps?

For cell A1:
=arrayformula(if(row(A:A)<=5000,"ABC DEF",))

Related

How to webscrape from Marketwatch Financials for Google Sheets

I want to scrape data from MarketWatch. I have a formula to pull from Finviz:
=value(regexextract(query(importhtml("http://finviz.com/quote.ashx?t="&$C7,"table",9),"select Col2 where Col1 = 'Income' ",0),"[-\d.]+"))
Note: The C7 box contains SBSW.
How do I scrape the Sales/Revenue of 2021 for the ticker SBSW. Here's the link:
https://www.marketwatch.com/investing/stock/SBSW/financials
The result should show 172.19
I tested using this formula, and it works for me:
=IMPORTXML("https://www.marketwatch.com/investing/stock/SBSW/financials", "//*[#id='maincontent']/div[6]/div/div[2]/div/div/table/tbody/tr[1]/td[6]/div/span")
And it looks like this:
You can get the xpath_query with the developer tools like this:
Edit answer, removing the B at the end
First option
If the letter is always "B."
=SUBSTITUTE(IMPORTXML("https://www.marketwatch.com/investing/stock/SBSW/financials", "//*[#id='maincontent']/div[6]/div/div[2]/div/div/table/tbody/tr[1]/td[6]/div/span"),"B","")
Second option
If the letter at the end always changes.
=REGEXEXTRACT(IMPORTXML("https://www.marketwatch.com/investing/stock/SBSW/financials", "//*[#id='maincontent']/div[6]/div/div[2]/div/div/table/tbody/tr[1]/td[6]/div/span"),"[0-9]+.+[0-9]")
Reference:
IMPORTXML
SUBSTITUTE
REGEXEXTRACT

Countif formula error checking duplicates in cells with formula in google sheets

This is my google script:
https://docs.google.com/spreadsheets/d/1A0zEN4zczP7aYn2aHdFjDxYgDJBi7R3S6NY_MTcM7YA/edit?usp=sharing
How it works:
In my sheet there is plan of production. Column E is only for help to calculate the date from the index used in column C (3M 000 00 0000 is equal to 3M [job_no] [month] [year]). At the top in cell E2 the is MAX fuction which is used to generate next job index with is generated by the script after pressing (+) button.
What I want to get:
Cells in E column calculate data from column C or show value "123456789" if index (3m xxx xx xxxx) in column C is duplicated. I want to get info in cell C2 that "Index 3M xxx xx xxxx is duplicated. Please remove duplicates".
What's the problem:
I use countif function to check for duplicates:
=countif(E5:E;"=123456789")
When I write this function in bar it shows good value (2) but if I click enter it keeps showing 0 in the cell (i8).
The same problem is with vlookup fuction to search the index and name of duplicated values from C column.
I guess the problem is that in E5:E cell have if formulas inside.
Please help me deal with it.
To detect duplicates in column C, use this formula
=if(arrayformula(sum(--(if(C8:C="";;countif(left(C8:C;14);left(C8:C;14)))>1)))>0;"Index 3M xxx xx xxxx is duplicated. Please remove duplicates";)
and with details ...
=if(arrayformula(sum(--(if(C8:C="";;countif(left(C8:C;14);left(C8:C;14)))>1)))>0;"Index """
&textjoin(", ";;unique(query({C8:C\arrayformula(countif(left(C8:C;14);left(C8:C;14)))};"select Col1 where Col1 is not null and Col2>1";0)))&
""" is/are duplicated. Please remove duplicates";)
with only the code (14 characters)
=if(arrayformula(sum(--(if(C8:C="";;countif(left(C8:C;14);left(C8:C;14)))>1)))>0;"Index """
&textjoin(", ";;unique(query({arrayformula(left(C8:C;14))\arrayformula(countif(left(C8:C;14);left(C8:C;14)))};"select Col1 where Col1 is not null and Col2>1";0)))&
""" is/are duplicated. Please remove duplicates";)

How to apply MID function to range or column in Google Sheets

I have a google sheet document. In there I have a column of text. I want to fill another column with substrings from each value from the first column, like this:
A | B
a.123 | 123
b.456 | 456
c.789 | 789
If a value is added to column A I want it to automatically appear in column B.
I tried (to no avail):
=ARRAYFORMULA(MID(A2:A, 3, 3))
=MID(ARRAYFORMULA({A2:A}), 3, 3)
=MID({A2:A}, 3, 3)
Which formula in the B2 cell will solve this? Or is it impossible to do from a single cell?
try like this:
=ARRAYFORMULA(MID(A1:A; 3; 3))
and this shall work too:
=ARRAYFORMULA(IFERROR(REGEXEXTRACT(A1:A; ".(\d+)")))
or even:
=ARRAYFORMULA(RIGHT(A1:A; 3))

Google Sheets combine Columns unless Column value is that of other columns value

I have a list of columns that contain city names:
E1 = New York
F1 = SF
G1 = Toronto
H1 = Seattle
Now lets assume A1 is Toronto - I now want to combine E:H except for A1.
The usual formula would be =E1&","&" "&F1&","&" "&G1","&" "&H1. However, since A1 is Toronto, G1 shouldn't be added.
How do I pull this off?
You could use formula:
=JOIN(", ",FILTER(E1:H1;E1:H1<>A1))
it uses filter to exclude A1 value (now I know filter works for both: vertical and horizontal ranges!).
And join is used to combine line into one string, and devide all values with comma and space.
Can you try with If condition to combine data from E:H. Eg: Below will merge if value is not same as A1.
=IF(E1=$A$1,"",E1&", ")&IF(F1=$A$1,"",F1&", ")&IF(G1=$A$1,"",G1&", ")&IF(H1=$A$1,"",H1&", ")
Please refer link here.

How do I conditionally format a cell in Google Sheets based on matching values in 2 other columns?

So here is what I am trying to do. I have a value in C1 let's say. I would like to like to highlight that cell if:
The value in B1 exists somewhere else in Column B(I'll call it Bn)
The values for A1 and An in this other row also match
So if B1 is 12:00 and A1 is Foo I want to highlight C1 if a cell(Bn) in Column B is 12:00 and the value of An is Foo.
Make sense?
1.Click the Format menu and select Conditional formatting....
2.Switch to the "Custom formula" option in the drop-down menu.
3.Add in the relevant formula, rules, and cell range.
Formula:
=AND(COUNTIF(A:A,A1)>1,COUNTIF(B:B,B1)>1)
Cell Range: $C - The entire C column
4.Click Save rules.

Resources