LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Looping "For Each" problem

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
--
Steve C
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
problem with Linking workbooks via "copy" and "paste link" Arkitek Excel Discussion (Misc queries) 0 December 19th 06 10:03 PM
Problem: Worksheets("New Style 2006").Unprotect Password:="naPrint" Karoo News[_2_] Excel Programming 1 January 30th 06 02:40 PM
Problem with "On error resume next" with "custom VLookup" Factivator Excel Programming 3 July 20th 04 04:42 PM


All times are GMT +1. The time now is 01:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"