LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
find name and insert address JL Excel Worksheet Functions 3 May 9th 07 05:25 AM
find text then insert new row above Nick Smith[_2_] Excel Programming 9 May 4th 06 12:59 PM
Find & Insert - Is this possible?? xhgroup Excel Discussion (Misc queries) 2 March 18th 06 05:31 AM
How do I find a value and insert new value SingaporeSling Excel Worksheet Functions 4 February 4th 05 06:03 AM
find row value, insert column gaba Excel Programming 0 October 18th 04 06:59 PM


All times are GMT +1. The time now is 05:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"