Macro to split weight into columns Request - excel

Let's say I have a column of numbers in A2 going down, to a random number, such as:
0.50
1.00
1.00
1.10
1.10
And I wanted a macro to split them into Major and Minor basically.. Anything before the Period, I want moved over to Column B. Anything after the Period I would like moved to Column C, and the . Just removed completely.
So
B C
0 50
1 00
1 00
1 10
1 10
Like that, Pretty simple. I don't know enough about Excel VBA to write it.

Just record the following macro:
Copy column A to B
Format column B as text
Data->TextToColumn on Column B with separator "."

I would just use formulas instead of VBA. Put this in B2:
=INT(A2)
and this in C2:
=(A2-B2)*100
Then copy and paste down.

Related

Input data into a 2nd cell, based on the value of a 3rd cell? (Like "conditional formatting")

B1 is a checkbox. If checked B1=1. A1 can range from 0 to 10. If B1 is checked I want A1 to automatically = 10. Exactly like conditional formatting would turn it green. I cant put the formula =IF(B1=1,10,"") into A1 though because I need to be able to input other values in A1 without erasing the formula. I need to be able to reuse the sheet multiple times.
Ex.
A B
1 10 x
2 9
3 10 x
4 4
As Scott commented, you'd need to use VBA to do exactly what you're asking. A work-around, though, would be to add a third column with:
=IF(B1="x",10,A1)
In this case, Column A would be the user-inputted number, Column B would be your "x", and Column C would give the final output: 10 if B has "x", and the number from A otherwise.

Dividing in excel by looking up another value

Looking to create a formula in excel that will divide a cell value by the last time a certain value had a once next to it:
A B C
20/04/2015 1.68 0
17/04/2015 1.68 0
16/04/2015 1.72 1
15/04/2015 1.66 0
So ideally it would be something that took 1.68 and divided it by 1.72, and it found 1.72 because of the 1 adjacent to it in column C.
You can use this formula in cell C2 then drag it to the bottom. =IF(C3=1,B2/B3,"")
To find the last value in column B that has a 1 next to it, you can use this formula:
=LOOKUP(2,1/(C:C=1),B:B)
So for the division, you could do something like:
=B1/LOOKUP(2,1/(C:C=1),B:B)

Send data (Job #) in one column to another spreadsheet, if another column contains data

Here is a sample of the data I'm using. The letters are the estimated time in each area of the workshop (i.e. A. is clean up, B. is welding etc.):
J/C # A. B. C. D. E. F. G. H. TOTAL
97647 45 45 90 30 120 330
97651 15 30 45
97626
99999 60 120 75 360 615
11111 90 30 15 15 150
12345 10 20 30 40 50 60 70 80 360
On another sheet I need a column of all the Job Card numbers (J/C #) for each workshop area. I would like these automatically to appear when the budgeted time is put into this first sheet.
For example the Welding Sheet will have the following J/C #.
97647
99999
12345
I have been trying INDEX and MATCH and LOOKUP and VLOOKUP functions, but haven't yet found a solution.
Is this possible?
I have a solution that works -- hopefully I can explain it clearly.
Let's say your table is on "Sheet1". Create new sheets, one for each workshop (so, I have a "Sheet1", "A","B","C",...,"H").
In your "A" sheet, put this formula in A1:
=IFERROR(INDEX(Sheet1!$A$2:$A$10000,SMALL(IF(Sheet1!B$2:B$10000<>"",ROW(Sheet1!A$2:A$10000)-ROW(Sheet1!A$2)+1),ROWS(Sheet1!A$2:A2))),"") Enter with CTRL+SHIFT+ENTER and drag down.
This will create a population of those Job #s that have some value under the "A." column in "Sheet1".
To use this formula for your "B." column, put this formula in sheet "B", cell A1:
=IFERROR(INDEX(Sheet1!$A$2:$A$10000,SMALL(IF(Sheet1!C$2:C$10000<>"",ROW(Sheet1!A$2:A$10000)-ROW(Sheet1!A$2)+1),ROWS(Sheet1!A$2:A2))),"")
Notice the only change is in the "SMALL(IF(Sheet1!C$2:C$10000<>..." That's because since you want to return any job numbers for your "B." column, which is in Column C of Sheet1. ...so for your "C." Sheet, in A1, put the above formula but using column D for the "Small(If(Sheet1!C$2:C$10000" part.
Does this make sense?
The only thing is that you'll need to tweak depending on your sheet names (since I don't know what C,D,E, etc. actually refer to).

Excel countif(s) multiples

I'm trying to calculate the count of multiple occurrences of a figure using countif.
I have the range set but I need a calculation which can count in multiples of 50 without me having to type thousands of versions of countif (=COUNTIF(B2:B5,">=50")-COUNTIF(B2:B5,">100" etc.).
Data Count
50 1
70 1
80 1
10 0
150 3
This data should show 6 but at the moment I'm getting 4.
First you can start by making bins. you can make it with Data analysis tool or half manual
Like in the example, on A2 enter 0 and on b2 enter =a2+50
Same goes for a3 enter =b2 and last on a4 =a3+50
Now you can drag it down as much as you like.
Instaed of using countif use sumif finction. let's assume your data is on cloumn H and the values you want to sum are in column I, then on c2 enter
=SUMIFS(I:I,H:H,">"&A2,H:H,"<="&B2)
you can drag it down as much as you like.
Simply use Excels ROUNDDOWN function:
e.g. for B2: =ROUNDDOWN(A2/50,0)

Count data if row is true excel

I have this Data:
var number
a 1
a 4
a 30
b 4
b 50
b 6
b 4
ab 1
I need to find the sum of each time a (var occurs X the number next column right) in excel.
In the case above the answer would be:
a = 36
b = 65
How can I write a formula for this in excel? Can I do this in excel?
Since you are counting the last one as well, I would use this formula:
=SUMIF(A:A,"*"&D2&"*",B:B)
Here, there is the value a in cell B2 and I can drag the formula down for B instead of typing a whole new formula. Handy if you have many like those to look for.
I assume that you have the table you published above in cells A1:B8. In order to do the calculating you would like to do you need to use the array-functionality in Excel. The following syntax in a cell will do:
=SUM(IF("a"=A1:A8,B1:B8))
However, instead of ENTER you need to press COMMAND+SHIFT+ENTER (I am on a Mac so it might be that Windows has a slightly different key combo. The result is that the formula now reads like:
{=SUM(IF("a"=A1:A8,B1:B8))}
This will give you 35 and not 36, but in a similar manner you could sum all the columns with 'ab' and then add that up to the sum of the 'a' columns.
Good luck!

Resources