ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Conditional Formating with Function (https://www.excelbanter.com/excel-programming/361222-conditional-formating-function.html)

Leitwolf25[_2_]

Conditional Formating with Function
 

Can it be true that it is impossible to contenate text with of different
format? It is easy to do with a Macro, but a Macro is not flexible
enough to contenate texts as it will not return a string.

The contidional formating option excel offers, is not even able to
solve simple problems as the above mentioned..

Can it be true ?


--
Leitwolf25
------------------------------------------------------------------------
Leitwolf25's Profile: http://www.excelforum.com/member.php...o&userid=34323
View this thread: http://www.excelforum.com/showthread...hreadid=541225


Brian Taylor

Conditional Formating with Function
 
You can use concatenated information in conditional formatting and you
can concatenate text with numbers. The only time concatenating gets
tricky is when you have dates (since they are really numbers). But you
can get around that with the date and time formulas.

In conditional formatting use the "formula is" option. Then use a
formula like this:

="I am number " & A1 = "I am number 1"

This will return a true or false statement. If the statement is true
the conditional formatting will be applied.

If you are talking VBA, it is also possible to concatenate text and
numbers:

Sub test()
Dim i As Integer
Dim str As String

i = 5
str = "I am " & i
MsgBox str
End Sub

This will return "I am 5"


Leitwolf25[_4_]

Conditional Formating with Function
 

Hi Brian

Sure its possible to contenate text with a funtion, easy as this:

Function AddIt(String1,String2)
AddIt = String1+String2
End Function

But that will not add a bold AND standard text. Also you can not set
any kind of font for the cell. Neither you can take over a textformat
like this "New York" into another cell. I think that its ugly that such
simple things shall be impossible in excel, even if you VBA
programing...


--
Leitwolf25
------------------------------------------------------------------------
Leitwolf25's Profile: http://www.excelforum.com/member.php...o&userid=34323
View this thread: http://www.excelforum.com/showthread...hreadid=541225


Leitwolf25[_3_]

Conditional Formating with Function
 

Hi Brian

Sure its possible to contenate text with a funtion, easy as this:

Function AddIt(String1,String2)
AddIt = String1+String2
End Function

But that will not add a bold AND standard text. Also you can not set
any kind of font for the cell. Neither you can take over a textformat
like this "New York" into another cell. I think that its ugly that such
simple things shall be impossible in excel, even if you VBA
programing...


--
Leitwolf25
------------------------------------------------------------------------
Leitwolf25's Profile: http://www.excelforum.com/member.php...o&userid=34323
View this thread: http://www.excelforum.com/showthread...hreadid=541225


Brian Taylor

Conditional Formating with Function
 
All formatting properties are properties of the cells. So everything
you mentioned can be done through the cell properties:

change font:
Range("A1").Font.Name = "Times New Roman"

bold with regular text:
ActiveCell.Characters(Start:=1, Length:=3).Font.FontStyle = "Regular"
ActiveCell.Characters(Start:=4, Length:=3).Font.FontStyle = "Bold"

Any property can be done in the same way, font, size, bold, color, etc.

So all you have to do is concatenate the string first and then apply
the formatting through the cell.


Leitwolf25[_5_]

Conditional Formating with Function
 

Hi Taylor

I know this, but i can not put this in a user definied workshee
function. if you try it will only cause an error..

anyway ... i try something else ;-

--
Leitwolf2
-----------------------------------------------------------------------
Leitwolf25's Profile: http://www.excelforum.com/member.php...fo&userid=3432
View this thread: http://www.excelforum.com/showthread.php?threadid=54122



All times are GMT +1. The time now is 08:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com