Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Enumerating SpecialCells

Can anyone help with showing how to enumerate a SpecialCells range using a
counter?

For example: with some text in cells B2, D2 and E5

For each cell in ActiveSheet.UsedRange.SpecialCells(xltextValues)
cell.Font.Bold = True
next cell

works just fine. However,

For i = 1 to ActiveSheet.UsedRange.SpecialCells(xlTextValues)
ActiveSheet.UsedRange.SpecialCells(xlTextValues).I tem(i).Font.Bold = True
next i

does not work. That is, it bolds cell B2 but not the others. In fact, if you
printout the rows and columns of the returned cells, then B2, B3 and B4 are
returned by the counter method (and these are the cells that actually get
bolded)!

Is this just a bug with SpecialCells and if so, is there a workaround?

Thank you
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Enumerating SpecialCells

Sorry, the second example that does not work should read:

For i = 1 to ActiveSheet.UsedRange.SpecialCells(xlTextValues).C ount
ActiveSheet.UsedRange.SpecialCells(xlTextValues).I tem(i).Font.Bold = True
next i

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Enumerating SpecialCells


You need to loop thru each area in the range.
'--
Sub vert()
Dim i As Long
Dim j As Long
With ActiveSheet.UsedRange.SpecialCells(xlTextValues)
For i = 1 To .Areas.Count
For j = 1 To .Areas(i).Cells.Count
.Areas(i).Cells(j).Font.Bold = True
Next 'j
Next 'i
End With
End Sub
--
Jim Cone
Portland, Oregon USA


"davea"
wrote in message
Sorry, the second example that does not work should read:

For i = 1 to ActiveSheet.UsedRange.SpecialCells(xlTextValues).C ount
ActiveSheet.UsedRange.SpecialCells(xlTextValues).I tem(i).Font.Bold = True
next i

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Enumerating SpecialCells

Thank you so much Jim :-)

I understood that there was a problem with non-contiguous cells but I didn't
think about areas as a solution.

Thanks again.
Reply
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
Enumerating the names of *subs* and *functions* David Schrader[_2_] Excel Programming 6 November 26th 07 08:18 PM
Enumerating PivotItems collection fails to display duplicate values kirk Excel Programming 2 October 17th 06 09:01 AM
SpecialCells help Graham Y Excel Programming 2 October 11th 06 05:16 PM
Enumerating Printers Michael D. Ober[_2_] Excel Programming 8 October 21st 03 01:25 PM
Enumerating a multi-dimensional array Robert Stober Excel Programming 7 September 13th 03 12:28 PM


All times are GMT +1. The time now is 10:25 PM.

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

About Us

"It's about Microsoft Excel"