View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dee Sperling[_2_] Dee Sperling[_2_] is offline
external usenet poster
 
Posts: 29
Default Find value in a column and insert rows above

It would probably help if I specified which line it stops on:
rw = Columns(col).Find("Y").Row

"Dee Sperling" wrote:

The titles will be New, Old, Existing, Deleted in that order from U to X.
Sorry I didn't make that clearer.

I put the code in my module but I get Run-time errro '91":
Opject variable or With block variable not set

I'm using Excel 2003, is that the cause?

"Bob Umlas, Excel MVP" wrote:

You didn't specify the "rules" for what titles to use, so this routine does
what you asked byt just puts the word "Title" in the yellow cell:

Sub InsertY()
For col = 21 To 24
rw = Columns(col).Find("Y").Row
Cells(rw, col).Resize(2).Insert shift:=xlDown
Cells(rw + 1, col).Interior.Color = vbYellow
Cells(rw + 1, col).Value = "Title"
Next
End Sub

Bob Umlas
Excel MVP

"Dee Sperling" wrote:

The set up looks like this:
ColU ColV ColW ColX
Y N N N
Y N N N
N Y N N
N N Y N
N N Y N
N N Y N
N N Y N
N N Y Y

Columns will always be U through X and will always be sorted in this order.
I need to find the first Y in each column and insert 2 rows above that row.
On the blank row above the first Y, I need to highlight in yellow and put
title in the first cell, such as New, Old, Existing, Deleted.

Any help would be greatly appreciated.

Thanks for your time,
Dee