View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Barb Reinhardt Barb Reinhardt is offline
external usenet poster
 
Posts: 3,355
Default Better way to select Cell in Range

Dim myRange as Excel.Range
Dim r as Excel.Range

set myRange = Range("K2:V2")

for each r in myRange
if r.value = "" then
r.select
end if
next r

That's how you do it, but selection really slows down execution.
--
HTH,

Barb Reinhardt



"Hal" wrote:

I have the range K2:V2. I want to start at K2 and check if the cell is empty.
If so select it, if not, check L2, M2 . . . V2 until the first empty cell in
this range is found, and then select it. The code below will work but I would
like to have something more professional.

Signed, Novice at work


If Range("K2").Value = "" Then
Range("K2").Select
Elseif Range("L2").Value = "" Then
Range("L2").Select
.
.
.
Else
Range("V2").Select