Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find Excel Ranges in VBA

Status
Not open for further replies.

Adamba

IS-IT--Management
Aug 3, 2001
72
GB
[afro] Hiya all

Im trying to write some code which will tell me how many products are within a selected range which is defined by the user.

I can easily loop through all the records in a sheet to find out whether they match my criteria but am struggling with pulling out just a certain range as i do not how to recieve the first and last row highlighted by a user.

[smarty]Is there anyway i can pull off the first and last row which are highlighted by the user as activecell.row only pulls out the 1 white cell.

Thanks in advance [thumbsup2] [pc3]
Adam [glasses]
 
hi adam
you could try this

Sub SomeRows()
Dim lRowOne As Long
Dim lRowTwo As Long
With Selection
lRowOne = .Rows.Row
lRowTwo = .Rows.Row + .Rows.Count - 1
End With
End Sub

seems to work on a single range no matter where the active cell (white one!) is

2 days to go
;-) If a man says something and there are no women there to hear him, is he still wrong?
 
Loomah,

Thanks!
After hours/days/months/years of work and its 4 lines!

lol, ohh well that'll teach me to try and find a complicated way of doing it :)

Thanks again! [pc3]
Adam [glasses]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top