ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cell value specific font size change (https://www.excelbanter.com/excel-programming/352328-cell-value-specific-font-size-change.html)

Geoff C

Cell value specific font size change
 
Would like to format font size in one column, according to a value in
another, e.g. if I have the data

A B
1 12 X
2 6 Y
3 16 X
4 9 Y
...

I would like the font size of the cells in column B to be the relevant
number in column A

(Going to use wingding arrows in B, but they won't display here)

Thanks,
Geoff.

Gary''s Student

Cell value specific font size change
 
For a single cell:

Sub size_it()
Range("B1").Font.Size = Range("A1").Value
End Sub


You can setup a loop to cover the full columns.
--
Gary's Student


"Geoff C" wrote:

Would like to format font size in one column, according to a value in
another, e.g. if I have the data

A B
1 12 X
2 6 Y
3 16 X
4 9 Y
..

I would like the font size of the cells in column B to be the relevant
number in column A

(Going to use wingding arrows in B, but they won't display here)

Thanks,
Geoff.


Ron de Bruin

Cell value specific font size change
 
Hi Geoff

You can try this event in the sheet module
If you fill in a number in A the font change in B

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("A:A"), Target) Is Nothing Then
If IsNumeric(Target) Then
Target.Offset(0, 1).Font.Size = Target.Value
End If
End If
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Geoff C" wrote in message ...
Would like to format font size in one column, according to a value in
another, e.g. if I have the data

A B
1 12 X
2 6 Y
3 16 X
4 9 Y
..

I would like the font size of the cells in column B to be the relevant
number in column A

(Going to use wingding arrows in B, but they won't display here)

Thanks,
Geoff.




Norman Jones

Cell value specific font size change
 
Hi Geoff,

Try:

'=============
Public Sub Tester()
Dim SH As Worksheet
Dim rng As Range
Dim rCell As Range

Set SH = Sheets("Sheet1") '<<==== CHANGE
Set rng = SH.Range("B1:B10") '<<==== CHANGE

For Each rCell In rng.Cells
With rCell
.Font.Size = .Offset(0, -1).Font.Size
End With
Next rCell

End Sub
'<<=============


---
Regards,
Norman



"Geoff C" wrote in message
...
Would like to format font size in one column, according to a value in
another, e.g. if I have the data

A B
1 12 X
2 6 Y
3 16 X
4 9 Y
..

I would like the font size of the cells in column B to be the relevant
number in column A

(Going to use wingding arrows in B, but they won't display here)

Thanks,
Geoff.




Geoff C

Cell value specific font size change
 
Sorry for being dim, but it's the loop I need help with!

"Gary''s Student" wrote:

For a single cell:

Sub size_it()
Range("B1").Font.Size = Range("A1").Value
End Sub


You can setup a loop to cover the full columns.
--
Gary's Student


"Geoff C" wrote:

Would like to format font size in one column, according to a value in
another, e.g. if I have the data

A B
1 12 X
2 6 Y
3 16 X
4 9 Y
..

I would like the font size of the cells in column B to be the relevant
number in column A

(Going to use wingding arrows in B, but they won't display here)

Thanks,
Geoff.


Gary''s Student

Cell value specific font size change
 
Hi Geoff:

Sub size_it()
Dim i As Integer
For i = 1 To 10
Cells(i, 2).Font.Size = Cells(i, 1).Value
Next
End Sub

The loop is set up to run over 10 items. This is an example of the
advantage of using CELLS() over RANGE() if you want to process blocks of
cells by row x column.
--
Gary's Student


"Geoff C" wrote:

Sorry for being dim, but it's the loop I need help with!

"Gary''s Student" wrote:

For a single cell:

Sub size_it()
Range("B1").Font.Size = Range("A1").Value
End Sub


You can setup a loop to cover the full columns.
--
Gary's Student


"Geoff C" wrote:

Would like to format font size in one column, according to a value in
another, e.g. if I have the data

A B
1 12 X
2 6 Y
3 16 X
4 9 Y
..

I would like the font size of the cells in column B to be the relevant
number in column A

(Going to use wingding arrows in B, but they won't display here)

Thanks,
Geoff.


Norman Jones

Cell value specific font size change
 
Hi Geoff.

Reading more carefully, change:

.Font.Size = .Offset(0, -1).Font.Size


to

.Font.Size = .Offset(0, -1).Value


If, however, you wish the font size to respond dynamically to changes in
column A values, try instead Ron de Bruin's suggestion.


---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Geoff,

Try:

'=============
Public Sub Tester()
Dim SH As Worksheet
Dim rng As Range
Dim rCell As Range

Set SH = Sheets("Sheet1") '<<==== CHANGE
Set rng = SH.Range("B1:B10") '<<==== CHANGE

For Each rCell In rng.Cells
With rCell
.Font.Size = .Offset(0, -1).Font.Size
End With
Next rCell

End Sub
'<<=============


---
Regards,
Norman




Geoff C

Cell value specific font size change
 
Thanks to all of you for your suggestions. Not only is my request answered,
I've learnt about seven other things!

"Geoff C" wrote:

Would like to format font size in one column, according to a value in
another, e.g. if I have the data

A B
1 12 X
2 6 Y
3 16 X
4 9 Y
..

I would like the font size of the cells in column B to be the relevant
number in column A

(Going to use wingding arrows in B, but they won't display here)

Thanks,
Geoff.



All times are GMT +1. The time now is 08:11 PM.

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