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

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

MrKowz

Well-known Member
Joined
Jun 30, 2008
Messages
6,653
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
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
 

mirabeau

Banned user
Joined
Nov 4, 2010
Messages
2,075
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)
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,028
Messages
5,856,932
Members
431,840
Latest member
simplysoph

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
Top