I am trying to use the substitute function in Excel to change the 05 in the first column to 04 as follows:
06-05NG22D021 --------------- 04NG22D021
06-05NG22D021-KP01 ---------- 06-04NG22D021-KP01
06-05NG22D021-M01 ----------- 06-04NG22D021-M01
06-05NG22D021-MK01 ----------- 06-04NG22D021-MK01
The problem is that when I use:
=SUBSTITUTE(A1, "-05", "-04")
it does not change the text to what it is supposed to be, it only changes when I remove '-0' like this
=SUBSTITUTE(A1, "5", "4")
it works correctly. The thing is that I have to include the '-0' in the string to ensure that the right part of the text is changed.
Sometimes it's because the cell or the column is locked.
Or also it can be the Format cells number category.
To unlock:
Right click on the cell or the column and in the "Format cells" window go to tab "Protection", uncheck "Locked" if checked.
To change format cells number category:
Right click on the cell or the column and in the "Format cells" window go to tab "Number", change category to "General" especially if "Text" is already selected.
Return to your cell and re-apply the formula.
You may be able to bypass the issue with:
=REPLACE(A1,5,1,4)
(copied down to suit) where the second parameter is the 5th character in A1 (which just happens to be 5).
REPLACE.
(Does not work for first row in your example however.)
Related
I can make an automatically calcuated value appear a cell using '=' operator. For example, when cell F20 is 200, I can enter in cell G20
=F20/10
Then, I see 20 in cell G20.
Now I want to add a note in cell G20 so that it appears
20
note 4)
I know I can do
=concatenate(F20/10," note 4)")
but this obviously shows
20 note4)
which is not what I want.
How can I put enter(new line) in the appended text in this case?
You can use CHAR(10) which is newline:
=concatenate(F20/10,CHAR(10),"(note 4)")
Make sure you have 'Wrap Text' turned on for it to work.
I have inserted a check box (form control) with the title "wall".
Next to this I have the cell stating "False" if unticked and "True" if ticked.
Next to this are two cells with the dimensions of the wall "length", "height". - Lastly is the cell containing "area of the wall".
I want to write an IF statement in the "area of the wall" cell so that when the check box IS ticked, the area of the wall is printed, and if it is NOT ticked it prints N/A If have written:
=IF((C2="TRUE"), (D2*E2), ("N/A"))
All that happens is the cell reads N/A, no matter whether the box is ticked or not. Any help please on how to correct this? Example
True should not be in quotes, it's treating it like a string when it's a boolean. Removing the quotes should work or writing TRUE()
The final formula should look like this:
=IF((C2=TRUE), (D2*E2), ("N/A"))
I would like to change the currency symbol in a cell depending on the value in another cell, in the row.
For example if cell A1 contains "EU" then cell A2 will be "€ 5.00" (If the calculation was 3+2), and if the content in cell A1 were to be changed to "GB" then £ 5.00 will display in A2.
Is is possible to do this in VBA? I would prefer NOT to do a simple IF statement.
You most certainly can! Utilize conditional formatting on your range with the currency value. Here is how I accomplished this in a test...
Select the first cell in your "amount" range and then click Conditional Formatting -> New Rule.
Select "Use a formula to determine which cells to format"
In the box, type =if([Cell w/ Country] = "USA", 1, 0 ). Note, [Cell w/ Country] is whatever cell that indicates the type of currency. In my example, the formula is =if($A6="USA", 1, 0). [Pay close attention to the cell reference $A6 - you want the formula to work for the entire column (in this example), so don't enter $A$6.]
After typing the formula, click the "Format" button.
Click on the "Number" tab and choose "Currency" in the Category list
Using the Symbol dropdown, select the symbol corresponding to the rule you just created - in this case, $, then click OK.
Finally, you're left with the Rules Manager window. You'll want to select the range that the rule will apply to. Enter the range, or click the range selector button and highlight the range. Then, click OK.
Here are some screenshots that might be helpful:
Swap around the Country, and the symbol changes.
If it only for one cell then a very short macro will do it.
just change for custom format as within the code:
Sub Macro2()
If Range("a1").Value = "EU" Then Range("A2").Select: Selection.NumberFormat = """€""#,##0"
If Range("a1").Value = "GB" Then Range("A2").Select: Selection.NumberFormat = """£""#,##0"
End Sub
You don't need VBA for this - just good 'ol conditional formatting. With your A2 cell selected, go to Home --> Conditional Formatting. Then click "New Rule" --> "Use a Formula to determine which cells to format".
For the GBP formatting, use the formula =$A$1="GB", then click "Format", go to "Number" along the top, choose "Currency", then just find the GBP symbol. Click "OK" all the way out. There you go!
For the EUR part, repeat the above, but instead use =$A$1="EU" and find EUR symbol in Currency.
I have a spreadsheet where the first column contains the text "user_#" in each row.
I need to replace the "#" in each row and rep[lace it with the row number such that
user_1
user_2
user_3
'
'
'
user_n
Is there a simple function that I can plug into the first row and then copy and drag so that each row will be filled in correctly?
you could simply have the text "user 1" in the first row and drag down then column. You need to choose the fill type to "fill series" in the "Auto Fill Options" box which appears when you drag down the column
Use this, where B3 is a cell on the same row as the one where you're putting this formula.
=CONCATENATE("USER_",ROW(B3))
Also, you can ="USER_"&ROW(B3) as an alternative. If you need a special format, like integer, you can make sure you get what you want by using this ="USER_"&TEXT(ROW(B3),"#"). Of course, this might be too much if you are using ROW(). I just added it in in case you wanted to reference a non-integer value.
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.