Excel: How to extract a substring by only knowing the strings location? - string

So basically, I am trying to attempt what the title says.
This may be easier to explain with an example:
I have a large string, such as - spreadsheet
A B C
______________________________________
1 | spreadsheet | Number | Letter
2 | | 1 | s
3 | | 2 | p
4 | | 3 | r
5 | | 4 | e
6 | | 5 | a
7 | | 6 | d
8 | | 7 | s
9 | | 8 | h
10| | 9 | e
11| | 10 | e
12| | 11 | t
Since the string spreadsheet has 11 characters, the numbers from 1 to 11 are created going down in a column. Each string that the number represents is then placed in the column next to it.
I searched for a function everywhere. Only found MID and FIND. Although both those functions require the knowledge of what string you are searching for exactly.
Does anyone have any idea on how to accomplish this?

Try this formula:
=IF(LEN($A$1)>=B2,MID($A$1,B2,1),"")
You could even get rid of column B by using the row function:
=IF(LEN($A$1)<=(ROW(C2)-ROW($C$1)),MID($A$1,ROW(C2)-ROW($C$1),1),"")

The formula =MID($A$1,B2,1) filled down in your C column will give you the result.

Related

MS Excel's alternative for ={A:A} formula in Google Sheets

This must be a simple thing to do but somehow I am unable to find answer to this question. In google sheets, if you want to reference an entire column (e.g Column A) you will put ={A:A} and the entire column will be referenced. How do you achieve similar thing in MS excel?
EDIT: (Asked in comments to post specific example)
Lets assume google sheets contain the following data:
| A | B | C |
| 1 | 5 | 9 |
| 2 | 6 | 0 |
| 3 | 7 | 9 |
| 4 | 8 | 0 |
Now if in cell D1 I type ={A:A}, the entire column A will be shown in column D.
| A | B | C | D |
| 1 | 5 | 9 |={A:A}
| 2 | 6 | 0 |
| 3 | 7 | 9 |
| 4 | 8 | 0 |
becomes
| A | B | C | D |
| 1 | 5 | 9 | 1 |
| 2 | 6 | 0 | 2 |
| 3 | 7 | 9 | 3 |
| 4 | 8 | 0 | 4 |
I dont have to drag the formula to the bottom or anything. It just shows the entire column
How do I do the exact same thing in excel?
It depends. For example:
=COUNTIF(A:A,"gold")
Excel does not support stuff like:
=COUNTIF(A12:A,"gold")

Transposing rows to column by row, not column (Microsoft Excel)

The Issue
I want to transpose data given in rows to columns.
The Problem
The Excel Paste Special -> Transpose on the full dataset goes by rows instead of by column.
Example
Data
| 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|----|
| 6 | 7 | 8 | 9 | 10 |
Desired Result
| 1 |
| 6 |
| 2 |
| 7 |
| 3 |
| 8 |
| 4 |
| 9 |
| 5 |
| 10 |
I'd like to automate this process, however, I'm not too familiar with VBA. Thanks for any and all help.
Here's one way.
Enter the formula shown in A4 and fill down:

Can I populate a column with conditional data while omitting empty rows or possibly autosort?

In one spreadsheet document, file.xlsx, I have 2 sheets. Sheet1 has the editable fields. Sheet 2's sole purpose is to read the data from Sheet1.
The point is to keep track of inventory and easily display items needed to be ordered.
Sheet1 'column a' is item number for ordering
Sheet1 'column b' is the number I have on hand
Sheet1 'column c' is the formula cell to find the number needed to be ordered
It looks something like this:
Document1:sheet1
A | B | C |
1 |txt1 | 1 | =10-b1 |
2 |txt2 | 0 | =10-b2 |
3 |txt3 | 13 | =10-b3 |
4 |txt4 | 5 | =10-b3 |
5 |txt5 | 2 | =10-b4 |
There is some if statement conditional formatting in the "C" column to check if the "B" column has a value HIGHER than 10 and if it hits true then the corresponding C cell is blank but for space, i'm summarizing here
Document1:sheet2
A | B |
1 |=if(sheet1!C1>0,Sheet1!A1,"") |=if(sheet1!C1>0,Sheet1!C1,"") |
2 |=if(sheet1!C2>0,Sheet1!A2,"") |=if(sheet1!C1>0,Sheet1!C2,"") |
3 |=if(sheet1!C3>0,Sheet1!A3,"") |=if(sheet1!C1>0,Sheet1!C3,"") |
4 |=if(sheet1!C4>0,Sheet1!A4,"") |=if(sheet1!C1>0,Sheet1!C4,"") |
5 |=if(sheet1!C5>0,Sheet1!A5,"") |=if(sheet1!C1>0,Sheet1!C5,"") |
If an item isn't to be ordered because stock is high, it doesn't show up in the list. This is ok. It looks like this:
Document1:sheet2
A | B |
1 | txt1 | 9 |
2 | txt2 | 10 |
3 | | |
4 | txt4 | 9 |
5 | | |
What I would like to see is:
Document1:sheet2
A | B |
1 | txt1 | 9 |
2 | txt2 | 10 |
3 | txt4 | 9 |
4 | | |
5 | | |
For 5 Items in the example, it doesn't seem that annoying, but in actuality I have 1200 potential rows and it varies between 200 to 800 actually populated each time i conduct inventory. The whole point is to have one continuous section of rows that I can select and print. Maybe some way of autosorting and placing the empty ones on the bottom?
I've taught myself excel. I don't know the advanced tricks and things.
I'm a typically a programmer but I've been tasked with this project and the guys upstairs want me to do it in excel.
i've overcomplicated this, to the max.
a simple sort putting the empty's at the bottom is the resolution.
not quite as automated as i'd like
but
it works.

Excel Creating a List from Beginning and End number AND tags

I am trying to create a list from an index of grouped values.
This is very similar to this, however my groups also have "tags" on then that complicate the listings.
Here is an example of my INDEX tab:
| A | B | C | D |
-------------------------
1 | 1 | 1 | 1 | CV |
2 | 1 | 2 | 2 | IS |
3 | 1 | 3 | 3 | IS |
4 | 2 | 4 | 5 | GN |
5 | 2 | 6 | 7 | PS |
6 | 4 | 8 | 11 | SQ |
7 | 2 | 12 | 13 | SS |
8 | 1 | 14 | 14 | AT |
9 | 15 | 15 | 29 | AT |
10| 4 | 30 | 33 | TYP |
Where A is the number of pages, B is the first page, C is the last page and D is the tag. I would also like to add columns such that I can keep a running tally of the tags.
| A | B | C | D | E | F |
---------------------------------------
1 | 1 | 1 | 1 | CV | CV1 | CV1 |
2 | 1 | 2 | 2 | IS | IS1 | IS1 |
3 | 1 | 3 | 3 | IS | IS2 | IS2 |
4 | 2 | 4 | 5 | GN | GN1 | GN2 |
5 | 2 | 6 | 7 | PS | PS1 | PS2 |
6 | 4 | 8 | 11 | SQ | SQ1 | SQ4 |
7 | 2 | 12 | 13 | SS | SS1 | SS2 |
8 | 1 | 14 | 14 | AT | AT1 | AT1 |
9 | 15 | 15 | 29 | AT | AT2 | AT16 |
10| 4 | 30 | 33 | TYP | TYP1 | TYP4 |
Note that the tag could occur multiple times and it may not be in sequential rows.
Here is what I want this to look like for my LIST tab:
| A |
---------
1 | CV1 |
2 | IS1 |
3 | IS2 |
4 | GN1 |
5 | GN2 |
6 | PS1 |
7 | PS2 |
8 | SQ1 |
9 | SQ2 |
10| SQ3 |
11| SQ4 |
and so on...
How do I add the additional columns to the INDEX tab via formulas?
How do I create the LIST via formulas? (...is this even possible?)
The formulas should be pretty simple to write. Just consider what you're trying to accomplish.
Your first formula (in column E) is just taking a running count of the tags (in column D). So you want to count all cells from the first tag up to the corresponding tag where the tag names are the same. That count is to be appended to the tag name.
=$D1 & COUNTIF($D$1:$D1, $D1)
The second formula (in column F) is just taking a running sum of the page counts (in column A). So you want to take the sum of all corresponding page counts from the first tag up to the corresponding tag where the tag names are the same. The sum is to be appended to the tag name.
=$D1 & SUMIF($D$1:$D1, $D1, $A$1:$A1)
Note that the column doesn't change nor does the starting rows of the ranges (hence the need to use absolute ranges). The only thing that changes are the rows of the tag and the row of the end range.
I don't think it would be possible to generate that list through simple formulas. As far as I know, formulas need to have a 1-to-1 correspondence with another range. A single range can yield multiple values so a formula just won't cut it. You'll need to write a VBA script to generate that.
Sub GenerateList()
Dim usedRange As Range
Dim count As Dictionary
Set usedRange = Worksheets("Index").usedRange
Set count = CountValues(usedRange)
Dim output As Range
Dim row As Integer
Dim key As Variant
Set output = Worksheets("List").Columns("A").Rows
output.ClearContents
row = 1
For Each key In count.Keys()
Dim i As Integer
For i = 1 To count(key)
output(row) = key & i
row = row + 1
Next i
Next key
End Sub
Function CountValues( _
usedRange As Range, _
Optional tagsColumn As String = "D", _
Optional valuesColumn As String = "A") As Dictionary
Dim tags As Range
Dim values As Range
Set tags = usedRange.Columns(tagsColumn).Rows
Set values = usedRange.Columns(valuesColumn).Rows
Dim map As New Dictionary
Dim tag As Range
For Each tag In tags
map(tag.Value) = map(tag.Value) + values(tag.row)
Next tag
Set CountValues = map
End Function
This uses a Dictionary so you'll have to reference the scripting runtime.
It sounds like you're just trying to get a list of "Unique Values" on a separate sheet that you can use as your list. Try these pages, there are multiple VBA methods to paste unique items in a range.
Also, Advanced Filter has an option to paste unique values to another location. So none of your repeat tags would appear in this list, only unique ones for your "LIST" tab.
Anyway, not sure if that's what you're wanting, but the question was a smidge vague.
Links here:
Create Unique list
Create Unique list 2

How to find the match between text that typo in Excel?

I have two columns of data with an hundred names on and I need to find the matches.
The problem is when names on the second column are not exactly the same as the first column. Its hard to match them with a hundred names.
Is there any formula in excel for at least give tolerance with the data like "Setyadi" with "Setiadi", or "Tak Jelan" with "Tak Lejan".
Thanks for the solution, it works, I edited this because I want to ask more,
I have another problem, could you help me again?
I have a data like this, I want to fill column C with a number according to match the name in column D with column A. The other problem is, I want to match the name that only in a group that mentioned in column E, even not in the same row.
From
A | B | c | D | E |
Setyadi | 1 | | Setiadi | 11 |
Tak Jelan | 2 | | Tak Lejan | 11 |
Gordon | 3 | | Herik | 12 |
Alex | 4 | | Goerdon | 12 |
Heri | 5 | | Alex | 12 |
Into
A | B | c | D | E |
Setyadi | 1 | 1 | Setiadi | 11 |
Tak Jelan | 2 | 2 | Tak Lejan | 11 |
Gordon | 3 | 5 | Herik | 12 |
Alex | 4 | 3 | Goerdon | 12 |
Heri | 5 | 4 | Alex | 12 |
What I need is, how can we compare the name in group that mentioned in column D, then We can automatically give the number in column C that coupling from column B.
Thanks in advance
You can use something like John Walkenbach's SOUNDEX() function:
http://spreadsheetpage.com/index.php/tip/searching_using_soundex_codes/
Then put the code in Excel:
http://www.contextures.com/xlvba01.html
Now, if you had this data:
A | B
Setyadi | Setiadi
Tak Jelan | Tak Lejan
Now you want to add a formula in C1 like:
=SOUNDEX(A1)
And copy that formula to C2, D1, and D2.
Now take a look at your data:
A | B | SOUNDEX(ColumnA) | SOUNDEX(ColumnB)
Setyadi | Setiadi | S330 | S330
Tak Jelan | Tak Lejan | T245 | T242
Notice how Setyadi and Setiadi are exactly the same, that's because they sound the same, which is why the code from the SOUNDEX function comes back like this.
Now when you look at the Tak Jelan entry, you see that there is a difference of 3 (from T245 to T242). Now, what I would do is creat a new formula where if the first letter is the same, then pull out only the number and compare how close they are like:
=IF(LEFT(C1,1)=LEFT(D1,1),STDEV.P(MID(C1,2,3),MID(D1,2,3)))
Then you can compare the std deviation.

Resources