S
Steve C
I have a column in which there are number values for each of five cells
(i.e., A1:A5), followed by a sum of those cells under that. The sum cell is
actually a merged cell (A6 & A7) and is bolded, font size 12. This pattern
continues down the column (5 individual cells with more numbers, then a
merged total under them) for hundreds of rows. My goal with my code is to
use a For Each statement that says for each bolded cell with font size 12 in
this selection, copy it, then switch to another workbook and paste a link to
that total. Then switch back, find the next bolded cell with font size 12,
and continue with each of the bolded cells until done.
My problem is that the For Each keeps going after the last bolded cell is
found; it isn't stopping at the last one, but rather restarts again with
first bolded cell. Here's my code; any help is appreciated!
Sub CopyAndPasteBoldedCells ( )
Dim BoldCell As Range
' Code here to select entire range in column
For Each BoldCell In Selection
With Application.FindFormat.Font
.FontStyle = "Bold"
.Size = 12
End With
Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=True).Activate
ActiveCell.Copy
' Code to activate other workbook and paste link, then return to this workbook
Next
(i.e., A1:A5), followed by a sum of those cells under that. The sum cell is
actually a merged cell (A6 & A7) and is bolded, font size 12. This pattern
continues down the column (5 individual cells with more numbers, then a
merged total under them) for hundreds of rows. My goal with my code is to
use a For Each statement that says for each bolded cell with font size 12 in
this selection, copy it, then switch to another workbook and paste a link to
that total. Then switch back, find the next bolded cell with font size 12,
and continue with each of the bolded cells until done.
My problem is that the For Each keeps going after the last bolded cell is
found; it isn't stopping at the last one, but rather restarts again with
first bolded cell. Here's my code; any help is appreciated!
Sub CopyAndPasteBoldedCells ( )
Dim BoldCell As Range
' Code here to select entire range in column
For Each BoldCell In Selection
With Application.FindFormat.Font
.FontStyle = "Bold"
.Size = 12
End With
Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=True).Activate
ActiveCell.Copy
' Code to activate other workbook and paste link, then return to this workbook
Next