small font in bracket

Jagat Pavasia

Active Member
Joined
Mar 9, 2015
Messages
406
Office Version
  1. 2021
Platform
  1. Windows
hello, dear sir/ madam,

my E6 to I500 have amount and then some text in bracket.
I want font size 8 in bracket.

example picture is below :
please help me with VBA code:

22.JPG





help me
 
Are you running the Macro or do you want it to work each time you type something?

As it is now, if you put your cursor inside the code you have pictured and then press the green play button at the top (in the ribbon) it should change the font.
You can also assign the code to a button within the worksheet you are working on.
 
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Are you running the Macro or do you want it to work each time you type something?

As it is now, if you put your cursor inside the code you have pictured and then press the green play button at the top (in the ribbon) it should change the font.
You can also assign the code to a button within the worksheet you are working on.
I don't want to assign macro to each time. I want automatically.


I want that if I type " 225.60 (D-45, D-56, ND-24) " then it should be automatically convert bracket font to size 8 like " 225.60
(D-45, D-56, ND-24) ".
In short, I want small size of font in the bracket.
Before bracket the font size is 12 and inside bracket it should be size 8.
 
Upvote 0
Try this Worksheet_Change event code. To implement ..
1. Right click the sheet name tab and choose "View Code".
2. Copy and Paste the code below into the main right hand pane that opens at step 1.
3. Close the Visual Basic window & test.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim Changed As Range, c As Range
  Dim p As Long
  
  Set Changed = Intersect(Target, Range("E6:I500"))
  If Not Changed Is Nothing Then
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    For Each c In Changed
      c.Font.Size = 12
      p = InStr(c.Value, "(")
      If p > 0 Then c.Characters(p, Len(c.Value)).Font.Size = 8
    Next c
    Application.EnableEvents = True
    Application.ScreenUpdating = True
  End If
End Sub
 
Upvote 0
Solution
Try this Worksheet_Change event code. To implement ..
1. Right click the sheet name tab and choose "View Code".
2. Copy and Paste the code below into the main right hand pane that opens at step 1.
3. Close the Visual Basic window & test.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim Changed As Range, c As Range
  Dim p As Long
 
  Set Changed = Intersect(Target, Range("E6:I500"))
  If Not Changed Is Nothing Then
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    For Each c In Changed
      c.Font.Size = 12
      p = InStr(c.Value, "(")
      If p > 0 Then c.Characters(p, Len(c.Value)).Font.Size = 8
    Next c
    Application.EnableEvents = True
    Application.ScreenUpdating = True
  End If
End Sub
THANK YOU MY DEAR.....................WORKING AS I WANT......


THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU
 
Upvote 0
You're welcome. Thanks for the follow-up. :)

For the future though, please note #14 of the Forum Rules and make your posts in the standard font size and without being all bold and all caps.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top