Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find and insert?
Hi, I have a sheet1 with data in column B. I have a sheet2 with also dat in column B. I have some code below to check if the data from sheet also exists on sheet1, and if not, then copy it to sheet1. The only problem is it works 1 time and then I get an error. I am novice in VBE so that's why the code will look unlogical. Can someone help me to create a better code that will work? Thanks i advance! Code ------------------- Sub FindAndInsert() For Each cell In Range("A3:A14") myvalue = cell.Value On Error GoTo NextPart myvalue1 = Sheets("Sheet1").Columns("A:A").Find(What:=myvalue ) GoTo Finalize NextPart: cell.Offset(-1, 0).Select myvalue2 = Selection.Value Sheets("Sheet1").Select Columns("A:A").Find(What:=myvalue2).Select Selection.Offset(1, 0).EntireRow.Insert Selection.Offset(1, 0).Select Selection.Value = myvalue Sheets("Sheet2").Select Finalize: 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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
find name and insert address | Excel Worksheet Functions | |||
find text then insert new row above | Excel Programming | |||
Find & Insert - Is this possible?? | Excel Discussion (Misc queries) | |||
How do I find a value and insert new value | Excel Worksheet Functions | |||
find row value, insert column | Excel Programming |