PDA

View Full Version : Copy Paste



96gtsmoker2
09-15-2008, 12:17 PM
Can anyone tell me how to write a VBA code to run an IF statement that says IF sheet1!A1 and A2 and A3 match Sheet2!A1, A2, and A3 the cut and paste Sheet2!A4 into sheet1!a4. If that makes since to anyone.

Bob Phillips
09-15-2008, 02:14 PM
Set sh = Worksheets("Sheet2")

With Worksheets("Sheet1")

If .Range("A1").Value = sh.Range("A1").Value And _
.Range("A2").Value = sh.Range("A2").Value And _
.Range("A3").Value = sh.Range("A3").Value Then

.Range("A4").Copy sh.Range("A4")
End If
End With

MaximS
09-15-2008, 02:20 PM
you can use folowing code:

Sub CopyPaste()
For i = 1 To 3
If Sheets("Sheet1").Cells(i, 1).Value = Sheets("Sheet2").Cells(i, 1).Value Then
Else
Exit Sub
End If
Next i
Sheets("Sheet2").Range("A4").Cut
Sheets("Sheet1").Range("A4").Insert
End Sub

96gtsmoker2
09-15-2008, 08:42 PM
Did not recognize the date to match. Any other ideas.

96gtsmoker2
09-15-2008, 08:51 PM
I have this VLOOKUP in Row H === =IF(IF(ISERROR(VLOOKUP(A1912,Data_2!$B$1:$L$57570,9,FALSE)),"None",VLOOKUP(A1912,Data_2!$B$1:$L$57570,9,FALSE))=0,"None",IF(ISERROR(VLOOKUP(A1912,Data_2!$B$1:$L$57570,9,FALSE)),"None",VLOOKUP(A1912,Data_2!$B$1:$L$57570,9,FALSE))). I just want to atleast put it in VBA but paste it in H.

MaximS
09-15-2008, 11:16 PM
Did not recognize the date to match. Any other ideas.


what do you mean by that??

Bob Phillips
09-16-2008, 12:27 AM
I am not sure what you are asking, but can't you simplify that formula to

=IF(ISERROR(VLOOKUP(A1912,Data_2!$B$1:$L$57570,9,FALSE)),"None",
IF(VLOOKUP(A1912,Data_2!$B$1:$L$57570,9,FALSE)=0,"None",VLOOKUP(A1912,Data_2!$B$1:$L$57570,9,FALSE)))

96gtsmoker2
09-16-2008, 05:02 AM
It would not return a copy paste. The dates are exactly the same.

MaximS
09-16-2008, 05:10 AM
Isn't that what you wanted??

Compare A1 A2 A3 from Sheet 1 with A1 A2 A3 from Sheet 2.
If they are the same cut A4 from Sheet 2 to Sheet 1 but
if not don't do anything.

96gtsmoker2
09-16-2008, 06:15 AM
MaximS is 100% correct. But in a macro or VBA form. I can record a macro to copy paste but I can not get the long VLOOKUP to work with it. That is what I am looking to do.

Bob Phillips
09-16-2008, 06:18 AM
Would you like to restate your problem again, from the start, completely, accurately, and in detail, as we have answered the question that you asked, and now you have introduced a new factor whilst that the solution ... did not match.

MaximS
09-16-2008, 06:26 AM
Sample file should give us more information.

96gtsmoker2
09-16-2008, 06:55 AM
What I need is to take the data from Data_1 page and seperate on the first three pages.
Date IS shows only the date issued. Date PD only shows those with date paid. And Date STP shows only those from
Date stop. Only when that is complete I want to take the data_1 and erase it. Then take Data_2 and match date, check #,
and amount with a vlookup. If matches and pastes the address from ADRess from DATA_2 onto the first three sheets. and
delete the information. Then when I go to add my next check book information in there it pastes the new stuff
from DATA_1 below the previous. Can any one help on this. It is to help balance my bills. Rows on all 5 tabs is A-H 1-60000. I have this VLOOKUP in Row H === =IF(IF(ISERROR(VLOOKUP(A1912,Data_2!$B$1:$L$57570,9,FALSE)),"None",VLOOKUP(A1912,Data_2!$B$1:$L$5757 0,9,FALSE))=0,"None",IF(ISERROR(VLOOKUP(A1912,Data_2!$B$1:$L$57570,9,FALSE)),"None",VLOOKUP(A1912,Data_2!$B$1:$L$57570,9,FALSE))). I want it in VBA code. And I can not attach the excel file here.

96gtsmoker2
09-16-2008, 07:12 AM
Here is the file

MaximS
09-18-2008, 04:08 AM
try this attachment I hope it's exactly what you want.