write an cell if another cell is bold

white_flag

Active Member
Joined
Mar 17, 2010
Messages
331
hello I have this code

Code:
Option Explicit
Public Sub test()

Dim my_range As Range
Dim c As Variant

Set my_range = ActiveSheet.Range("D:D")

For Each c In my_range
    If c.Font.Bold = True Then
 ' here I have no idea
    End If
Next c
    

End Sub

example if E30 is bold .. then the code will write in F30 text from F29
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Based on what I think you're trying to do, try the following. Note it will be more efficient if you restrict the range of cells to your used range, but I can't code for that since you haven't posted a sample of your data

Code:
Public Sub test()

Dim my_range As Range
Dim c As Variant

Set my_range = ActiveSheet.Range("E:E")

For Each c In my_range
    If c.Font.Bold = True Then Cells(c.Row, 6).Value = Cells(c.Row - 1, 6)
 Next c
    

End Sub
 
Upvote 0
and how the first row can be avoid?

It can't - in my post, I suggested restricting the range, which I can help you with if you post a sample of your data.

Look at it another way - supposing the cell in row 1 was bold - what would you want to happen?
 
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,223
Members
452,896
Latest member
IGT

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