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: 7
Default help with syntax for copy and pasting rows across sheets

Following is the code I am using to check for a value in sheet1 against sheet
2. If value not found in sheet2 then I want to copy the value from sheet1 and
paste it at the bottom of the list of values in sheet2. What is not working
is the statement that I am using to copy the row from sheet 1 and pasting it
to sheet2

Cel.EntireRow.Copy destination:=Sht2.Cells(r, 1)


Following is the code

Private Sub CommandButton2_Click()

Dim r As Long 'Last row of data on Sheet 1 (row number)
Dim c As Range 'Range/counter
Dim Rng As Range 'Row 2 to row 'r' (above) as counter
Dim Cel As Range 'Cell value to find from Sheet1 on Sht2
Dim Sht1 As Worksheet 'Sheet1
Dim Sht2 As Worksheet 'Sheet2
Dim Sht3 As Worksheet 'Sheet3


Set Sht1 = Sheets("sheet1")
Set Sht2 = Sheets("sheet2")
Set Sht3 = Sheets("sheet3")

'Get last row Sheet 1, Column a
r = Sht1.Range("a65536").End(xlUp).Row

'Start with Sheet1
Sht1.Activate

'Set 'counter' as first row of data to last row of data (Col a)
Set Rng = Range(Cells(2, 1), Cells(r, 1))

'For cells first to last (counter)
For Each Cel In Rng
'find first Sheet1.Cell.Value in sheet 2
With Sht2.Cells
Set c = .Find(Cel, LookIn:=xlValues)
If c < "" Then GoTo phred
r = Sht2.Range("a65536").End(xlUp).Row + 1
Cel.EntireRow.Copy destination:=Sht2.Cells(r, 1) ' this is not
working...
End With
phred:
MsgBox "went to phred"
Next
End Sub

any tips or recommendations is much appreciated.
 
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
Copy and pasting values of filtered rows Jammings Excel Discussion (Misc queries) 1 August 5th 09 06:45 PM
Copy pasting Rows, but need to Delete any Shapes/Pictures that are within copied rows Corey Excel Programming 2 August 1st 07 02:02 AM
Copy and Pasting into new Sheets [email protected] Excel Programming 2 January 14th 06 12:32 PM
Pasting on Filtered Data Sheets without pasting onto hidden cells CCSMCA Excel Discussion (Misc queries) 1 August 28th 05 01:22 PM
Copy and pasting sheets with merged cells John Corbin[_2_] Excel Programming 2 December 19th 04 03:14 PM


All times are GMT +1. The time now is 08:55 AM.

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

About Us

"It's about Microsoft Excel"