View Single Post
  #14   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Highlight first blank cell in column

Jacob found a possible problem area with the code I gave you, so here are
two different one-liners that should work correctly under all
circumstances...

Columns("D").SpecialCells(xlCellTypeBlanks)(1).Sel ect

or

Columns("D").Find("", After:=Cells(Rows.Count, "D")).Select

--
Rick (MVP - Excel)


"Ryan H" wrote in message
...
I should work on one liner coding. I'm falling in love with loops, which
could be dangerous at times assuming they take longer to execute.
--
Cheers,
Ryan


"Rick Rothstein" wrote:

No looping is necessary Ryan, this single line of code will do the same
thing...

Range("D1").End(xlDown).Offset(1 + 2 * (Range("D1") = "")).Select

--
Rick (MVP - Excel)


"Ryan H" wrote in message
...
So you just want to "Select" the cell? Use this,

Sub Highlighter()

Dim lngLastRow As Long
Dim rng As Range

lngLastRow = Cells(Rows.Count, "D").End(xlUp).Row

For Each rng In Range("D1:D" & lngLastRow)
If IsEmpty(rng) Then
rng.Select
Exit For
End If
Next rng

End Sub
--
Cheers,
Ryan


"gotroots" wrote:

Hi

Both solutions have performed there function, only the cell that is
color
highlighted is not "click" hightlighted, if you can understand what I
mean.
Like, if you were to select a cell with the mouse. Like an OnClick
event.



"Jacob Skaria" wrote:

You can avoid looping if D13 is a blank cell (no formula within).

Range("D1").End(xlDown).Offset(1).Interior.ColorIn dex = 3

--
Jacob


"gotroots" wrote:

What code do I need to allow the first blank cell found in a range
to
be
highlighted.

Example

D1:D12 contains a value
D13 is the first blank cell in "D"

C5 is hightlighted

when code is run D13 is highlighted

Thank you if you can help with this.


.