Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Different way of selecting range

The following code works fine to determine if the currently selected
cell is in the desired range:

Sub SelectCellinRange()
Dim rStart, rEnd As Range
Dim lRow, lCol As Long
Dim lBRow As Long


Set rStart = Range("B4")

lRow = rStart.End(xlDown).Offset(-1, 0).Row
lCol = Cells(lRow, Columns.Count).End(xlToLeft).Column

Set rEnd = Range(rStart, Cells(lRow, lCol))

If Not IsCellInRange(ActiveCell, rEnd) = True Then
MsgBox "Please select a county!"
End
End If
End Sub

The problem is, that in one of the sheets there are blanks in the
bottom rows, and the full range that the selected cell can be in is not
identified. I want to count the columns in row 4 rather than the last
row in the range. How do I do that?
When I try to put in Row("4:4") in place of lRow in the lCol line, XL
doesn't know what a row is. And you can't have rows in Activesheets. So
I can't figure out how to get it to figure out what a row is in this
situation. I think I could if I defined what worksheet I'm in and
passed that name from the macro calling this one into this one, but
that seems uneccessarily complicated.
Thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Different way of selecting range

Sorry, meant to take out the Dim lBRow as long line before posting.
It's something I tried to get this to work. Ignore it.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Different way of selecting range

Thanks Tom! Boy do I feel dumb! Making it more complicated as usual!

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
Selecting range in list of range names depending on a cell informa Courreges Excel Discussion (Misc queries) 2 June 19th 06 10:59 AM
Help please in selecting range dependent on another range MickJJ Excel Programming 2 January 10th 05 12:01 PM
Selecting a Range inside a range hcova Excel Programming 0 July 13th 04 03:26 PM
selecting range Bob Phillips[_5_] Excel Programming 0 September 5th 03 05:41 PM
Selecting A Range Patrick Molloy Excel Programming 0 July 22nd 03 07:54 AM


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