Copy Bolded Cells to an Array

mgoose288

New Member
Joined
Mar 23, 2011
Messages
2
Hi.
This seems like a simple thing but it is giving me problems
I would like to copy all of the bolded cells in a range that are not 0 into an array.
This is what I have right now.


Dim NOC(1 To 70)
Range("N2:AA:25).Select
Dim iCell As Range
k = 1
For Each iCell In Selection
if iCell.Font.Bold = True Then
NOC(k) = iCell.value
k = k + 1
End If
Next
Range("G1:G70").Value = NOC

However when I do this it just places the first bolded value into the array over and over again.

Hope someone can help
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Welcome to the forums!

That shouldn't have even compiled, since your Select line had some syntax errors. Try this:

Code:
Public Sub mgoose()
Dim NOC(1 To 70)
Dim rng As Range
Set rng = Range("N2:AA25")
Dim iCell As Range
k = 1
For Each iCell In rng
    If iCell.Font.Bold = True Then
        NOC(k) = iCell.Value
        k = k + 1
    End If
Next iCell
Range("G1:G70").Value = NOC
End Sub
 
Upvote 0
Try the following change to your code. As pointed out, others may be needed.
Rich (BB code):
Dim NOC(1 To 70)
Range("N2:AA:25).Select
Dim iCell As Range
k = 1
For Each iCell In Selection
if iCell.Font.Bold = True Then
    NOC(k) = iCell.value
    k = k + 1
End If
Next
Range("G1:G70").Value = Application.Transpose(NOC)
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,729
Members
452,939
Latest member
WCrawford

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