Currency in Excel - excel

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.

Related

MS Excel : Identify Cell containing 2 or more "#" / two or more email addresses

What formula should I use to identify a cell containing two or more "#" ?
For example, I copied thousands of emails from a sheet and pasted it to a new sheet (emails are all in one column only) but there's a case that a cell may contain two or more emails [eg. abcd#efg.comhijk#lmn.com], what I want is to highlight/identify those cell containing such so that I can easily fix or remove it from the list.
Any response to this will be highly appreciated. Thanks.
To "Highlight/identify" your cells... Highlight your cells and choose "Conditional formatting" -> "Highlight Cell Rules" -> "Text that contains" In the "Format cells that contain text" field, enter ##* and choose your highlight color.
You can count the "#" symbol in the cell with this formula and if it is more than 2 then it will indicate with a TRUE flag
=IF(SUMPRODUCT(LEN(A1)-LEN(SUBSTITUTE(A1,"#","")))=2,"TRUE","FALSE")
Please see the image below for the formula used in excel
Or you can put this formula in conditional formatting to highlight the cells when TRUE()
=IF(SUMPRODUCT(LEN(A1)-LEN(SUBSTITUTE(A1,"#","")))=2,TRUE(),FALSE())

Excel Formula Issue Using IF

If E10='Dealer', Then SUM of D10=0;If E10=Customer, Then SUM of D10=B6/2
E10 is a drop down Menu. It has one other option of 'Pick One' that has no relevancy.
I'm not sure what I'm missing, or if I am able to set it up like this.
Put this formula inside D10 because that is the cell you want to change.
=IF(E10="Dealer",0,IF(E10="Customer",B6/2,""))
When the Dropdown is at "Pick One" this formula will default to "" (empty cell) you can change that to anything you want.

Customize Conditional Formatting in Excel 2010

I'm unable to create a rule in Conditional Formatting for this requirement. I was tried using this option "Use a formula to determine which cells to format" inside the rule but didnt get proper formulae.
My Requirement:
If I change the Activity value to Completed in column A then accordingly the font color should be in (Sky blue) and font size is (10) in columns B and C.
If I change the activity value to Delayed in column A then the font color should be in (Red) and font size is (Default or no change) in columns B and C.
Also if I manually type to change the Activity type from To Do to Completed then the Final Date column field value should be automatically filled with the current or Today's date which is as on date.
What formulae I can use for this requirement? How?
Changing the text format is easy to solve with Conditional Formatting, changing the cell's text to today's date requires VBA.
1. Text format
Select cells B2:C10
Create a conditional format with "Use a formula to determine which cells to format". Enter this formula:
=$A2="Completed"
Click the 'Format' button and apply the blue text color and your desired font size.
Repeat the steps using this formula:
=$A2="Delayed"
Apply the red font color.
2. Enter today's date via VBA
Open the VBA editor with Alt+F11
Double click the worksheet on the left hand panel where your Activity table is placed (i.e. Sheet1).
Enter this code in the right hand code panel:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 And Target.Value2 = "Completed" Then
Cells(Target.Row, 3).Value = Date
End If
End Sub

I use kingsoft spreadsheets. Want a cell to change colour if the cell is false

I have this formula:
=Y606=SUM(I606:X606)
Can anyone please advise me how to make the cell colour change colour if false?
As follows from the header of your question, you are using Kingsoft Spreadsheets.
So, you need to use Conditional Formatting.
If you have this formula i.e. in cell Z606 than
1. select Z606 cell
2. select "Format" -> "Conditional Formatting"
3. select "Cell value is" and "equal to" in the left
4. enter FALSE in the right textbox
5. choose format style you want to apply
6. press "ok" and that's all:)
Result:

Add common prefix to all cells in Excel

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.

Resources