Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default HIGHLIGHTING ROWS & COLUMNS

I have a worksheet that is 61 columns wide and 21 rows
high. I would like to be able to highlight the entire Row
and Column, relative to the cell that is active (up and
down, left and right), within this grid. Can anyone
suggest anything, perhaps in conditional formatting, that
might achieve this task?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default HIGHLIGHTING ROWS & COLUMNS

You know selection is generally something to be avoided, but I assume
you really want it. Conditional formatting is one cool way but it would
seem to be "expensive" to have to format every cell on the sheet. AAR
for any such matters the first step should always be to check with Chip:
http://search.freefind.com/find.html...atch+ALL+words

and John:
http://search.atomz.com/search/?sp-q...6ae-sp00000000

You may be particularly interested in this instead of selection:
http://www.cpearson.com/excel/banding.htm

Since this is the programming area one programming solution is
sCol = Mid(ActiveCell.Address, 2, InStr(2,ActiveCell.Address,"$") - 2)
sRow = ActiveCell.Row
Range(sCol & ":" & sCol & "," & sRow & ":" & sRow).Select

If you want to limit it to 61 columns etc. modify the following.
Range(sCol & "1:" & sCol & "65536" & ",A" & sRow & ":IV" & sRow).Select

sCol is awkward because I don't know a direct way to get the column
letter. Perhaps someone else can supply that.

An alternate solution may be available with EntireRow et al.
You might poke around .Resize but I believe it's only for a rectangle.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default HIGHLIGHTING ROWS & COLUMNS

Dim oRng As Range
Set oRng = Union(Columns(sCol), Rows(iRow))
oRng.Select


To be further anal, you can also replace the above with
Union(Columns(sCol), Rows(iRow)).Select

But nice code :)
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default HIGHLIGHTING ROWS & COLUMNS

Since this
Range(sCol & ":" & sCol & "," & sRow & ":" & sRow).Select

Selects the entire sheet, it would be easier to just do

cells.Select

--
Regards,
Tom Ogilvy

"Wild Bill" wrote in message
...
Thanks for the augmentation. Clever alpha parse there :) But I'll go
on a limb and say that
Range(sCol & ":" & sCol & "," & sRow & ":" & sRow).Select
is only one operation, and saves a call to Union besides <g

The IV and 65536 were only to illustrate that he could substitute a
limited range, as I indicated. And his "grid" may not start in A1, so
he may need a tad of work coming up with the substitutions.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default HIGHLIGHTING ROWS & COLUMNS


"Wild Bill" wrote in message
...
Thanks for the augmentation. Clever alpha parse there :) But I'll go
on a limb and say that
Range(sCol & ":" & sCol & "," & sRow & ":" & sRow).Select
is only one operation, and saves a call to Union besides <g


Yes but
Range(sCol & ":" & sCol & "," & sRow & ":" & sRow).Select
Range(sCol & "1:" & sCol & "65536" & ",A" & sRow & ":IV" & sRow).Select
is two selects, so the Union replaces the both. Agree that 2 selects may
well be less costly than a union (probably so small as to be
non-measuraeable though), but there is a natural aversion to selects (vbg

The IV and 65536 were only to illustrate that he could substitute a
limited range, as I indicated. And his "grid" may not start in A1, so
he may need a tad of work coming up with the substitutions.


By using the Columns and Rows properties, I avoid the need to put in any
cell references. I thought that this
sCol = Left(ActiveCell.Address(True, False), _
1 - (ActiveCell.Column 26))
was what you were referring to when you said
sCol is awkward because I don't know a direct way to get the column
letter. Perhaps someone else can supply that.

although yours seemed quite direct to me.

Regards

Bob





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default HIGHLIGHTING ROWS & COLUMNS

Perhaps this is version-dependent. I see a "black X" selected.

On Mon, 18 Aug 2003 09:13:10 -0400, "Tom Ogilvy"
wrote:

Since this
Range(sCol & ":" & sCol & "," & sRow & ":" & sRow).Select

Selects the entire sheet, it would be easier to just do

cells.Select


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default HIGHLIGHTING ROWS & COLUMNS

Tom,

I think it only selects the row and column of the activecell, not the whole
sheet (at least it does with me, and it seems to be what Bill is suggesting
will happen).

Regards

Bob

"Tom Ogilvy" wrote in message
...
Since this
Range(sCol & ":" & sCol & "," & sRow & ":" & sRow).Select

Selects the entire sheet, it would be easier to just do

cells.Select

--
Regards,
Tom Ogilvy

"Wild Bill" wrote in message
...
Thanks for the augmentation. Clever alpha parse there :) But I'll go
on a limb and say that
Range(sCol & ":" & sCol & "," & sRow & ":" & sRow).Select
is only one operation, and saves a call to Union besides <g

The IV and 65536 were only to illustrate that he could substitute a
limited range, as I indicated. And his "grid" may not start in A1, so
he may need a tad of work coming up with the substitutions.





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default HIGHLIGHTING ROWS & COLUMNS

No, my mistake:

I typed it in as

Range("B:B","5:5").Select

Where it actually produces

Range("B:B,5:5").Select

subtle difference with dramatic difference in results.

--
Regards,
Tom Ogilvy

"Wild Bill" wrote in message
...
Perhaps this is version-dependent. I see a "black X" selected.

On Mon, 18 Aug 2003 09:13:10 -0400, "Tom Ogilvy"
wrote:

Since this
Range(sCol & ":" & sCol & "," & sRow & ":" & sRow).Select

Selects the entire sheet, it would be easier to just do

cells.Select




  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default HIGHLIGHTING ROWS & COLUMNS

Yes but
Range(sCol & ":" & sCol & "," & sRow & ":" & sRow).Select
Range(sCol & "1:" & sCol & "65536" & ",A" & sRow & ":IV" & sRow).Select
is two selects


No, they're two versions of [essentially] the same select. How about
giving them a try :)

but there is a natural aversion to selects (vbg


union or not, do you realize that you still select?!

I thought that this
sCol = Left(ActiveCell.Address(True, False), _
1 - (ActiveCell.Column 26))
was what you were referring to when you said
sCol is awkward because I don't know a direct way to get the column
letter. Perhaps someone else can supply that.

although yours seemed quite direct to me.


Having to use instr and mid does feel like a bit more work than ideal.
At least one of the pair would be avoided if there were a variable
(/property,etc.) with "$R" or ideally "R" instead of what .address
gives, "$R$2" (all specific columnar references I found were numeric,
not alphabetic). AAR you have some clever Boolean logic in its stead.
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default HIGHLIGHTING ROWS & COLUMNS


"AmendConstitution_ArnoldForPresident"
wrote in message om...

No, they're two versions of [essentially] the same select. How about
giving them a try :)


Of course you are right. I did try it, but I pasted both into my code, and
so they both executed, and I didn't immediately spot it. Noticed it almost
immediately I posted it. My mistake.

Regards

Bob


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
Highlighting Columns Gord Dibben Excel Discussion (Misc queries) 0 February 17th 10 07:56 PM
Highlighting Rows with VB. Xman Excel Worksheet Functions 12 January 23rd 09 12:48 PM
Highlighting rows and columns klsb123 Excel Discussion (Misc queries) 1 October 16th 08 11:46 PM
Highlighting selected cells/rows/columns [email protected] New Users to Excel 0 May 21st 08 09:13 PM
Highlighting rows/columns is there a way to darken the highlight? Jerri Lynne Excel Discussion (Misc queries) 1 February 23rd 08 08:39 PM


All times are GMT +1. The time now is 10:33 AM.

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"