View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
leonidas[_66_] leonidas[_66_] is offline
external usenet poster
 
Posts: 1
Default Find and insert?


Hi Bernie,

Sorry, I think I haven't explained the situation enough.
Sheet2 is a copy of sheet1 (this is to track changes afterwards an
sheet1 cannot be changed after making the copy (protected)). Sheet2 ha
also another user than sheet1. The user of sheet2 can delete and inser
rows in column A (only on specific rows, the rest is protected). Whe
the user of sheet2 is ready, a resume is made on a new sheet.
The data of sheet1 is copied to this new sheet, but because the user o
sheet2 has made some changes, these changes should also be visible i
the resume. Deleting data in sheet2 is no problem, because the origina
data is in sheet1. But inserting is a problem. These inserted dat
should be copied to the resume.
For example:
If sheet1 has data:
a (protected)
b
c
d (protected)
e
f
g
h
and the user of sheet2 changes this to:
a (protected)
c
d (protected)
x
y
z
e
f
g
h
it should be possible to allways copy the new data to the right plac
when checking the data a row above like in the code below. Only thi
code doesn't work.
Could you please help me fix the code. Thanks again!


Code
-------------------
Sub FindAndInsertOK()
Dim cell As Range

For Each cell In Sheets("Sheet2").Range("A3:A14")
myvalue = cell.Value
If IsError(Application.Match(myvalue, _
Worksheets("Sheet1").Range("A:A"), False)) Then
cell.Offset(-1, 0).Select
myvalue1 = Selection.Value
Sheets("Sheet1").Select
Columns("A:A").Find(What:=myvalue1).Select
Selection.Offset(1, 0).EntireRow.Insert
Selection.Offset(1, 0).Select
Selection.Value = myvalue
End If
Next cell

End Su
-------------------

--
leonida
-----------------------------------------------------------------------
leonidas's Profile: http://www.excelforum.com/member.php...fo&userid=3537
View this thread: http://www.excelforum.com/showthread.php?threadid=56783