ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to search the upper and lower of a range (https://www.excelbanter.com/excel-programming/415849-how-search-upper-lower-range.html)

leungkong

how to search the upper and lower of a range
 
I want to search the upper and lower row of a range.
for example,
Range("B3:E10")
Upper = "B"
Lower = "E"

Thanks.

joel

how to search the upper and lower of a range
 
Why? There are usually much better ways of doing this rather than get the
letters. Explain the problem, maybe there is a better solution.


Sub test()

Set MyRange = Range("B3:E10")
FirstColNum = MyRange.Column
FirstColLetter = MyRange.Address
'remove $ sign
FirstColLetter = Mid(FirstColLetter, 2)
'remove rest of string, look for $
FirstColLetter = Left(FirstColLetter, InStr(FirstColLetter, "$") - 1)

SecondColNum = MyRange.Column + MyRange.Columns.Count - 1
SecondColLetter = MyRange.Address
'remove everything before colon
SecondColLetter = Mid(SecondColLetter, InStr(SecondColLetter, ":") + 1)
'remove $ sign
SecondColLetter = Mid(SecondColLetter, 2)
'remove rest of string, look for $
SecondColLetter = Left(SecondColLetter, InStr(SecondColLetter, "$") - 1)

End Sub

"leungkong" wrote:

I want to search the upper and lower row of a range.
for example,
Range("B3:E10")
Upper = "B"
Lower = "E"

Thanks.


Alan Beban[_2_]

how to search the upper and lower of a range
 
leungkong wrote:
I want to search the upper and lower row of a range.
for example,
Range("B3:E10")
Upper = "B"
Lower = "E"

Thanks.

What do you mean you want to "search it"? Loop through it? Find a
specific value in it? Something else?

Alan Beban


All times are GMT +1. The time now is 02:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com