I am trying to concatenate content of two different columns row wise but I am not getting a way by which I can do this with a single formula/condition.
name Surname
A B
C D
E F
.............
And I want to display:
A B
C D
E F
.....
I know the formula to concatenate like =CONCATENATE(A1," ",B1).
But I know that I can do this for individual rows. Is there any way by which I can do this for all rows simultaneously with single formula dependoing on number of rows?
I use a macro to do that, the macro works with selected text, you can easily change it to suit your solution:
sub Append_Text()
'Add right text to the left text
for each c in Selection
if c.Value <> "" then c.Offset(0,2).Value = c.Value & c.Offset(0,1).Value
next
end sub
You select the left side values and run the macro, it would be a good idea to assign a shortcut for the macro to speed up the process.
Let me know if this will work for you.
If you want to achieve this using a single formula such as =A1&B1,
then first convert your data as table (select a cell in your data, use the Ribbon menu Insert -> Table ) and then use the formula which will fill down automatically.
Related
There are a lot of questions on how to multiply all values by some other cell or to move all values to another cell based on some value, but what I want is to take, in the example image below:
All the values that I have selected and divide by 2. I do not want another column, I just want to change all those values in the spread sheet and divide them by 2, the values themselves should change.
I have not found an answer for this any where and I sure it is super simple. For example, in:
base_damage_mod selected column, 0.03 would become: 0.015.
The only way I know to do this is manually, and that's a lot of work ...
Whats the easiest way to do this?
The easiest way to do this is by writing a macro, like in the following example:
Sub Divide_by_2()
For Each c In Selection:
If c <> "" Then
c.Value = c.Value / 2
End If
Next c
End Sub
In order to launch this, you need to select your cells (no need to copy, or press Ctrl+C), and then launch the macro.
As far as the source code is concerned, this is pretty obvious, except for the c <> "" part: I have added this in order to avoid the value 0 being filled in in empty cells.
Is there a way to do this without VBA, without macros?
Yes, there is, but it involves you creating a new column, in there type a formula, then copy the values of that formula into again another column and remove the first two columns, in other words: it's quite Messi :-)
If column C is empty (if not, temporarily insert a column), enter a 2 there next to every used column D item (*).
Copy all of column C, and "Paste Special" onto column D using Operation>Divide.
(*) If there are too many items to manually do the "2", copy this formula down column C =IF(ISBLANK(D1),"",2) and it will add them. After this, convert column C from formulas to values by copying it and using "Paste Values" to paste it back. (Special Operations won't work on formulas)
I have an excel file with 15000 rows of data. I have numerical values in Columns D & E . I have to calculate the difference between D & E and store it in F using VBA. I am new to VBA Help is appreciated.
Is it absolutely necessary that you use VBA for this ? If I understand the question correctly this would be much easier to do with excel formulas rather than using an array and having to loop through.
In cell F1 you need to type the following formula:
= D1-E1
Be sure to include the equals sign. Then press enter. Double click the bottom right corner of cell in F1 and it should auto fill all the way down.
Hope this helps. This is my first post so hopefully I haven't done anything wrong !
For data between rows 2 and 15000, run:
Sub SplitTheDifference()
Range("F2:F15000").Formula = "=D2-E2"
End Sub
The formulas adjust as we move down the columns
If we need values rather than formulas in column F, use:
Sub SplitTheDifference()
With Range("F2:F15000")
.Formula = "=D2-E2"
.Value = .Value
End With
End Sub
Hey All on my excel sheet there is a column that i need to concatenate. I need the combine all the rows in the same colors into one row, I need to do this for a list of 10000+ rows. Any ideas?
ALSO THE COLORS I added in to explain what I need to combine, there are no colors in the spreadsheet.
In a helper column (just any empty column, I Assume AA here, change that to your needs) starting with row 1 (I assume the colored column is F, change that to your needs):
=IF(LEN(A2),F1,F1&", "&AA2)
copy down till the end
copy whole column
paste as values only (to column F)
Set filter to show only rows which are empty in column A
select all
delete all
turn off the filter
finished :)
If you are willing to use VBA it could be as simple as inserting this into a module and then using it with other regular functions to build your string:
Function WhatColor(r As Range) As Long
WhatColor = r.Cells.Interior.Color
End Function
If it has to be a "somewhat" native function, check out the GET.CELL answer here.
Sorry this may seems super basic but im struggling with excel at the moment as I am self teaching. I'm looking for a function which will search a column and replace all instances of "Big" with 1 and "Tiny" with a 0.
If your data is in column B, then in column A you could have something like
=if(B1="Big",1,if(B1="Tiny",0,B1))
Then copy that formula down your column to make a new column with the replacements you want made.
If you don't want to create a new column, but just modify the old one, then you could use vba, like so
Sub myReplace()
for i = 1 to ActiveSheet.UsedRange.Rows.Count
if cells(i,1) = "Big" then
cells(i,1) = 1
elseif cells(i,1) = "Tiny" then
cells(i,1) = 0
end if
next i
end sub
This assumes your column of interest is column A.
Highlight the column, hit CTRL+H to bring up the search and replace box, tell it what you want to do.
If you prefer a formulaic way and the words are within a text string, =SUBSTITUTE(text,old_text,new_text,[nth_appearance]) would do the job as well.
I have a column with some text in each cell.
I want to add some text, for example "X", at the start of all cells. For example:
A B
----- >>>> ----
1 X1
2 X2
3 X3
What is the easiest way to do this?
Type this in cell B1, and copy down...
="X"&A1
This would also work:
=CONCATENATE("X",A1)
And here's one of many ways to do this in VBA (Disclaimer: I don't code in VBA very often!):
Sub AddX()
Dim i As Long
With ActiveSheet
For i = 1 To .Range("A65536").End(xlUp).Row Step 1
.Cells(i, 2).Value = "X" & Trim(Str(.Cells(i, 1).Value))
Next i
End With
End Sub
Select the cell you want to be like this,
Go To Cell Properties (or CTRL 1)
under Number tab
in custom
enter
"X"#
Select the cell you want to be like this, go to cell properties (or CTRL 1) under Number tab in custom enter "X"#
Put a space between " and # if needed
Select the cell you want,
Go To Format Cells (or CTRL+1),
Select the "custom" Tab, enter your required format like : "X"#
use a space if needed.
for example, I needed to insert the word "Hours" beside my numbers and used this format : # "hours"
Enter the function of = CONCATENATE("X",A1) in one cell other than A say D
Click the Cell D1, and drag the fill handle across the range that you want to fill.All the cells should have been added the specific prefix text.
You can see the changes made to the repective cells.
Option 1:
select the cell(s), under formatting/number/custom formatting, type in
"BOB" General
now you have a prefix "BOB" next to numbers, dates, booleans, but not next to TEXTs
Option2:
As before, but use the following format
_ "BOB" #_
now you have a prefix BOB, this works even if the cell contained text
Cheers, Sudhi
Michael.. if its just for formatting then you can format the cell to append any value.
Just right click and select Format Cell on the context menu, select custom and then specify type as you wish... for above example it would be X0. Here 'X' is the prefix and 0 is the numeric after.
Hope this helps..
Cheers...
Go to Format Cells - Custom. Type the required format into the list first. To prefix "0" before the text characters in an Excel column, use the Format 0####. Remember, use the character "#" equal to the maximum number of digits in a cell of that column. For e.g., if there are 4 cells in a column with the entries - 123, 333, 5665, 7 - use the formula 0####. Reason - A single # refers to reference of just one digit.
Another way to do this:
Put your prefix in one column say column A in excel
Put the values to which you want to add prefix in another column say column B in excel
In Column C, use this formula;
"C1=A1&B1"
Copy all the values in column C and paste it again in the same selection but as values only.
Type a value in one cell (EX:B4 CELL). For temporary use this formula in other cell (once done delete it). =CONCAT(XY,B4) . click and drag till the value you need. Copy the whole column and right click paste only values (second option).
I tried and it's working as expected.