In vim 8, ctrl+A / crtl+X increases and decreases number for visual selected columns, respectively.
1
2
3
ctrl+A
2
3
4
However, both are not worked to multiple columns.
Is there any simple method to increase/decrease a constant number for all columns selected? Like,
1 10
2 11
3 12
Any commands
2 11
3 12
4 13
Not exactly what you asked for but might be close enough:
CTRL-V and select all the columns you want to change.
Do CTRL-A. This will increment the numbers of the first column. At this point, the cursor should be at the top of the first column.
Do w to move the cursor to the second column.
Do . to increment the second column.
Keep doing w and . until you're done with all the columns.
This also works if you only select one column in step 1, but only if all the columns have the same width or if the selected column is the widest.
This may not work correctly if the columns do not have the same number of rows.
Using command line and submatch:
:%s/\d\+/\=submatch(0)+1/g
Related
I have an excel chart with thousands of Samples in one column. The sample appears in a row three times matching up to a different column called Target which is normal. I am looking to seeing if the sample duplicates 4,5 or 6 times and add a "-r2" to the end of the Sample name, and if the Sample duplicates 7,8, or 9 times and add a "-r3" to the end of the Sample name. I am trying to find a formula that ignores the first three times a Sample is counted and only count duplicates from ranges 4-6 as "-r2" and 7-9 as "-r3".
Below is an example of what I would want my new column (called "New Sample") to look like. It's worth noting that not every sample is duplicated more than 3 times, sometimes 6 or 9.
Sample
New Sample
Target
1
1
top
1
1
middle
1
1
bottom
1
1-r2
top
1
1-r2
middle
1
1-r2
bottom
1
1-r3
top
1
1-r3
middle
1
1-r3
bottom
2
2
top
2
2
middle
2
2
bottom
3
3
top
3
3
middle
3
3
bottom
3
3-r2
top
3
3-r2
middle
3
3-r2
bottom
Use COUNTIFS:
=A2&IF(COUNTIFS($A$2:A2,A2,$C$2:C2,C2)>1,"-r"&COUNTIFS($A$2:A2,A2,$C$2:C2,C2),"")
If the third column does not exist or we cannot refer to it:
=A2&IF(COUNTIFS($A$2:A2,A2)>3,"-r"&INT((COUNTIFS($A$2:A2,A2)-1)/3)+1,"")
I need to generate a sequential number in col C based on the value in col B. The number needs to follow the text System and each time the sequence number in col B resets, I need the numbering to reset but start at the next nearest base number, as shown below
Example data...
A ¦ B ¦ C
1 1 End Item
2 2 System10
3 3 System11
4 3 System12
5 2 System20
6 3 System21
7 3 System22
8 2 System30
9 3 System31
I have tried the following formula =IF(B1=B2, "System" & C1+1, "System" & 1)
However this doesn't give me the numbers starting at 10.
Any help would be greatly appreciated.
As a first cut at this, you could try:
=IF(C1="End Item","System10",IF(B2>=B1,"System"&RIGHT(C1,LEN(C1)-6)+1,"System"&ROUNDUP(RIGHT(C1,LEN(C1)-6),-1)))
This does allow for numbers of more than two digits, but doesn't increase to the next multiple of ten if the current number is an exact multiple of ten.
One way of getting round this would be to add a small increment:
=IF(C1="End Item","System10",IF(B2>=B1,"System"&RIGHT(C1,LEN(C1)-6)+1,"System"&ROUNDUP(RIGHT(C1,LEN(C1)-6)+0.1,-1)))
i would like to count number for every 7 rows, data are in one column. i use this formula, but it is not working.
from B8 to B14329, for every 7 rows, count number if it is equal to 3. so i know how many 3 in every 7 rows.
=COUNTIFS(B8:B14329, OFFSET($B$7,(ROW()-12)*7,0,7,1),B8:B14329,=3)
Thanks a lot!
i want something like this:
data count
3
2
3
1
3
3
1 4
1
2
2
3
3
1
1 2
.....
....
...
Simple and easy:
=SUMPRODUCT((B8:B14329=3)*(MOD(ROW(B8:B14329),7)=1))
Just change the =1 to your needs. To start with row 1 =1, 2 =2 ... 6 =6, 7 =0. This way, to start count at row 8 it is =1
EDIT: having your exaple now, you want something completely different... lol.
=IF(MOD(ROW(),7)=0,COUNTIF(A8:A14,3),"")
Put this in row 14 and then drag down... change the =0 as you need it.
Here's what I would do
Add a new column with the row index (8 to 14239) in your case
Add Yet another column, with a formula to tell whether the column you just added is a multiple of 7. Put it's value like "TRUE" or "FALSE"
You can use the MOD function to check the remainder of the division.
= MOD ( Number , Divisor )
By now, you should have, aside from the columns you already have, something like:
8-----FALSE
9-----FALSE
10-----FALSE
11-----FALSE
12-----FALSE
13-----FALSE
14-----TRUE
15-----FALSE
Once you have that, just apply a filter on the "TRUE/FALSE" column, select the "TRUE" values and you will be able to count the number of "3"s on the actual value column, by also using a filter on it.
I hope it helps, and it's easier than a really messy formula.
I have a very long column( 50000 rows) and I want select a range (sample) of cells (number of rows) in order to apply certain calculations. You don't have to worry about the calculation formula. Here I just need help on how to do the sampling. The range(sample) should be changing based on window size. The window size is a number I can choose .i.e such in the example below I chose the window size to be 4. In other words, I need to have samples, and these samples are based on selected number of rows of the long column. The size(number of rows) for all of the samples will be equal to the window size. However, each sample is shifted by one from the main column. Now, the samples should be in seperate columns , and thats why I need to copy the selection in each sample in its required column.For illustration purpose, assume the below example:
let assume the window size( number of rows)=4
test
1
2
3
4
5
6
7
8
9
10
The expected output should be :
main col sample1 sample2 sample3 sample4 sample5 sample6
1 1 2 3 4 5 6
2 2 3 4 5 6 7
3 3 4 5 6 7 8
4 4 5 6 7 8 9
5
6
7
8
9
10
each sample of size 4 rows , however, each new sample shifs by 1 from the main column. Note we get 6 samples to cover the whole number of rows in the main column. What basically should be done: sample1 will be from row1-to-row4 from the main col. Now, sample2 will be 4 values, however, from row2-to-row5, from the main column. sample3 will be 4 values, from row3-to-row6, and so on until we cover the whole range of the main column. So there are two main process, selection and copy of selection.
I have tried to use the offset and other logical function ... but it didn't work. I don't want to use Macros or VBA... Is there are any built in functions to solve the problem.?
This is basically a variation of a range transpose. Use the formula:
=INDEX($A:$A,COLUMN()+ROW()-2,1)
Then just copy to whatever window size you want. It will automatically move down the main column by one row for every column over it is. The result looks like this (you are responsible for copying the formula to the right size):
Bonus, you can automate the column header "Sample N" with:
="Sample " & COLUMN()-1
I have a line of numbers from 0 to 100. They follow each other like usual:
1 2 3 4 5 6 7 8 9 10 ... and so on --> ... 100
But I need to change their direction from right to left, like this:
100 <-- and so on ... 10 9 8 7 6 5 4 3 2 1 0
Is there some special tool for this operetion?
Each number is in its individual cell and horizontally: 1 in [A1], 2 in [B1], 3 in [C1], and so on.
If this is exaclty what you need, you can simply enter 100 in A1, 99 in B1, select the 2 cells and drag the formula to the right (by clicking on the little square at the bottom right of the selected range).
If your actual problem is a bit more complex and you need to sort the data in descending order, you could:
transpose it to make it vertical (Copy / Paste Special and select transpose)
sort the data set with the standard sorting feature
transpose it again back to its original range