LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Macro to select a variable range

I see you worked the starting row out. This will color the
entire range yellow. It is difficult to solve the starting row problem
because the information you have provided to describe the sheet
contents is a little ambiguous. Howeve, if you have no data on the
except in columns D through N, then it is possible to define the
starting row with the UsedRange property. Then you could use
the code below to get the range and color it yellow.

Dim DlstRow As Long, Rw1st As Long
Rw1st = ActiveSheet.UsedRange.Row
DlstRow = Cells(Rows.Count, 4).End(xlUp).Row
Set myRange = Range("D" & Rw1st & ":N" & DlstRow)
cRng = myRange.Address
Range(cRng).Interior.ColorIndex = 6
End With

However, If you have any data in any row above the range you want to color
code, then the code above will fail for your purposes. But, if you want to
think about it a while and start a new thread with a good descriprion of what
you are working with, and what you are trying to do, someone will help you to
do it.


"Elmtree" wrote:

I've made some changes, however 1 thing eludes me, The starting Row.For my
example I assume starting on row 29.

-------

Dim DlstRow As Long
DlstRow = Cells(Rows.Count, 4).End(xlUp).Row
Set myRange = Range("D29:N" & DlstRow) 'Get current range
' MsgBox myRange.Address 'Display current range address

Range(myRange.Address).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With

Set myRange = Range("D29:D" & DlstRow) 'Get current range

Range(myRange.Address).Select
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With

-------

This macro selects my range, colors it yelow, then goes to column D and
unhighlights it. All works like I need it to, but the starting row is my
problem. I can live with starting on row 29. (For now!)

thanks for your assistance!!!!!


Mike

Elmtree wrote:
Set myRange = Range("D1:N" & DlstRow)

I do not start at Row 1.

Mike

OK, let me throw a curve:

[quoted text clipped - 7 lines]

Mike





 
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
Select variable range ewan7279 Excel Programming 1 September 5th 07 09:46 AM
Select a variable range Eduardo Excel Programming 7 August 8th 07 01:46 PM
Use a Variable to select a range Connie Excel Discussion (Misc queries) 3 October 19th 06 05:48 PM
select a variable range evil baby[_15_] Excel Programming 4 March 8th 06 08:38 PM
Select a Range Through a Variable GoFigure[_9_] Excel Programming 3 December 6th 05 01:02 PM


All times are GMT +1. The time now is 11:00 PM.

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"