Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 161
Default Formatting non-contiguous cells

Hi,

I need to be able to format some cells that are not adjacent to each other.
I can do it on a cell-by cell basis:

CurrentCellNew.Select
With Selection.Interior
.ColorIndex = 15
End With
CurrentCellNew = CurrentCellNew.Offset(0, 1)
CurrentCellNew.Select
With Selection.Interior
.ColorIndex = 15
End With
CurrentCellNew = CurrentCellNew.Offset(0, 12)
CurrentCellNew.Select
With Selection.Interior
.ColorIndex = 15
End With

but this is really ugly. How do I select a number of cells (their offset
position from CurrentCellNew will always be known)?

This is in Office '07 under Vista.

TIA

Dave
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Formatting non-contiguous cells


Dim allCells as range

set allCells = CurrentCellNew
set allCells = Application.Union(allCells,CurrentCellNew.Offset(0 ,1))
set allCells = Application.Union(allCells,CurrentCellNew.Offset(0 ,12))

allCells.Interior.ColorIndex

"Risky Dave" wrote:

Hi,

I need to be able to format some cells that are not adjacent to each other.
I can do it on a cell-by cell basis:

CurrentCellNew.Select
With Selection.Interior
.ColorIndex = 15
End With
CurrentCellNew = CurrentCellNew.Offset(0, 1)
CurrentCellNew.Select
With Selection.Interior
.ColorIndex = 15
End With
CurrentCellNew = CurrentCellNew.Offset(0, 12)
CurrentCellNew.Select
With Selection.Interior
.ColorIndex = 15
End With

but this is really ugly. How do I select a number of cells (their offset
position from CurrentCellNew will always be known)?

This is in Office '07 under Vista.

TIA

Dave

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 161
Default Formatting non-contiguous cells

Spot on - my thanks

"incre-d" wrote:


Dim allCells as range

set allCells = CurrentCellNew
set allCells = Application.Union(allCells,CurrentCellNew.Offset(0 ,1))
set allCells = Application.Union(allCells,CurrentCellNew.Offset(0 ,12))

allCells.Interior.ColorIndex

"Risky Dave" wrote:

Hi,

I need to be able to format some cells that are not adjacent to each other.
I can do it on a cell-by cell basis:

CurrentCellNew.Select
With Selection.Interior
.ColorIndex = 15
End With
CurrentCellNew = CurrentCellNew.Offset(0, 1)
CurrentCellNew.Select
With Selection.Interior
.ColorIndex = 15
End With
CurrentCellNew = CurrentCellNew.Offset(0, 12)
CurrentCellNew.Select
With Selection.Interior
.ColorIndex = 15
End With

but this is really ugly. How do I select a number of cells (their offset
position from CurrentCellNew will always be known)?

This is in Office '07 under Vista.

TIA

Dave

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
Non-contiguous cells Kokomojo Excel Discussion (Misc queries) 2 November 6th 07 04:09 PM
Copy and Paste LAST ROW of data: non-contiguous Row, contiguous Column Sam via OfficeKB.com Excel Programming 8 November 5th 07 07:18 PM
Subtotaling non-contiguous cells David N. Ballew Jr.[_2_] Excel Worksheet Functions 2 May 2nd 07 10:04 PM
counting cells that are 0 in a range of non-contiguous cells Mark Excel Worksheet Functions 9 March 14th 07 02:45 PM
Testing for contiguous cells jamieuk Excel Programming 2 January 8th 04 05:23 PM


All times are GMT +1. The time now is 04:19 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"