Hi all,
I tried searching the form to see if I could find an issue similar to mine - I came up empty.
I'm trying to apply the phone number format ([<=9999999]###-####;(###) ###-####) to each phone number cell in column D if the cell in column N is equal to "United States of America".
Here is the macro I've come up with;
Sub Format_USA_PhoneNumbers()
Columns("D:D").Select
Selection.NumberFormat = "[<=9999999]###-####;(###) ###-####"
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$N$1=""United States of America"""
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
ExecuteExcel4Macro "(2,1,""[<=9999999]###-####;(###) ###-####"")"
Selection.FormatConditions(1).StopIfTrue = False
End Sub
Example of what I'm looking to do:
If N35 = "United States of America"
D35 format is (###) ###-####
If N99 = "Canada"
D99 = 0
If N106 = "United Kingdom"
D106 = 0
If N888 = "United States of America"
D888 format is (###) ###-####
The problem I'm having is that every time I run the macro, I receive an error;
Run-Time Erro '1004';
The formula you typed contains an error. When I debug it, it highlights this line;
ExecuteExcel4Macro "(2,1,""[<=9999999]###-####;(###) ###-####"")"
Can someone please assist with a recommendation / solution to what I'm trying to achieve? I'd very much appreciate it!
Using Excel 2010
I tried searching the form to see if I could find an issue similar to mine - I came up empty.
I'm trying to apply the phone number format ([<=9999999]###-####;(###) ###-####) to each phone number cell in column D if the cell in column N is equal to "United States of America".
Here is the macro I've come up with;
Sub Format_USA_PhoneNumbers()
Columns("D:D").Select
Selection.NumberFormat = "[<=9999999]###-####;(###) ###-####"
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$N$1=""United States of America"""
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
ExecuteExcel4Macro "(2,1,""[<=9999999]###-####;(###) ###-####"")"
Selection.FormatConditions(1).StopIfTrue = False
End Sub
Example of what I'm looking to do:
If N35 = "United States of America"
D35 format is (###) ###-####
If N99 = "Canada"
D99 = 0
If N106 = "United Kingdom"
D106 = 0
If N888 = "United States of America"
D888 format is (###) ###-####
The problem I'm having is that every time I run the macro, I receive an error;
Run-Time Erro '1004';
The formula you typed contains an error. When I debug it, it highlights this line;
ExecuteExcel4Macro "(2,1,""[<=9999999]###-####;(###) ###-####"")"
Can someone please assist with a recommendation / solution to what I'm trying to achieve? I'd very much appreciate it!
Using Excel 2010