Hi Paul,

The code works. However, it doesn't achieve the desired result. The code 
doesn''t show all the updated data in the next blank row. It doesn't seem 
to compare the database in both workboooks.  


Cheers 

On Tuesday, 26 January 2016 21:20:47 UTC+8, Paul Schreiner wrote:
>
> I updated the macro to this.
> give it a try:
>
> Option Explicit
> Sub test()
> Dim varSheetA As Variant
> Dim varSheetB As Variant
> Dim strRangeToCheck As String
> Dim strRangeToC As String
> Dim iRow As Long
> Dim iCol As Long
> Dim wbkA As Workbook
> Dim eRow As Long
>
> Set wbkA = Workbooks.Open(Filename:="C:\temp\vba\fortest.xlsx")
> strRangeToCheck = "A:C"
> strRangeToC = "C:E"
> 'Debug.Print Now
> varSheetA = wbkA.Worksheets("Sheet1").Range(strRangeToCheck)
> varSheetB = ThisWorkbook.Worksheets("Sheet1").Range(strRangeToC)
> 'Debug.Print Now
> 'Warning:  VarSheetA and VarSheetB result in arrays of the ENTIRE 
> respective workbook
> '       using LBound() to UBound() causes the ENTIRE workbook to be 
> processed,
> '       regardless of how much is actually used.
> '  I'd suggest using something like:
> '  thisworkbook.select
> '  MaxRow = ActiveCell.SpecialCells(xlLastCell).Row
> '  MaxCol = ActiveCell.SpecialCells(xlLastCell).Column
> '  For iRow = 1 to MaxRow
> '      For iCol = 1 to MaxCol
> '--------------------------------------
> For iRow = LBound(varSheetA, 1) To UBound(varSheetA, 1)
>     For iCol = LBound(varSheetA, 2) To UBound(varSheetA, 2)
>         If varSheetA(iRow, iCol) = varSheetB(iRow, iCol) Then
>             ' Cells are identical.
>             ' Do nothing.
>         Else
>             eRow = ThisWorkbook.Worksheets("Sheet1").Cells(Rows.Count, 
> 3).End(xlUp).Row + 1
>             ThisWorkbook.Sheets("Sheet1").Range("C" & eRow & ":E" & 
> eRow).Value = wbkA.Sheets("Sheet1").Range("A" & iRow & ":C" & iRow).Value
>             Exit For
>         End If
>     Next
> Next
> wbkA.Close savechanges:=False
> End Sub
> *Paul*
> -----------------------------------------
>
>
>
>
>
>
>
> *“Do all the good you can,By all the means you can,In all the ways you 
> can,In all the places you can,At all the times you can,To all the people 
> you can,As long as ever you can.” - John Wesley*
> -----------------------------------------
>
>
> On Monday, January 25, 2016 8:14 PM, Kat <kather...@gmail.com 
> <javascript:>> wrote:
>
>
>
> Hi Paul,
>
> Please see attached the fortest.xlsx file for your attention.
>
>
> Cheers
>
> On Tuesday, 26 January 2016 04:18:22 UTC+8, Paul Schreiner wrote:
>
> you've only sent the "Tested.xlsm" file
> Can you please include the fortest.xlsx file?
> Otherwise, I would need to GUESS what  file looks like.
> It LOOKS like you're comparing columns A-C in one workbook to range C-E in 
> another.
>
> However:
> you have:
>
> Set varSheetA = wbkA.Worksheets("Sheet1")
> Set varSheetB = ThisWorkbook.Worksheets(" Sheet1")
>
> followed by:
> varSheetA = Worksheets("Sheet1").Range( strRangeToCheck)
> varSheetB = Worksheets("Sheet1").Range( strRangeToC)
>
> which will cause varSheetA and varSheetB to be defined for the currently 
> active workbook.
>
> If you can send me a sample data file, I'd be glad to put something 
> together for you.
>
>  
> *Paul*
> ------------------------------ -----------
>
>
>
>
>
>
>
> *“Do all the good you can,By all the means you can,In all the ways you 
> can,In all the places you can,At all the times you can,To all the people 
> you can,As long as ever you can.” - John 
> Wesley*------------------------------ 
> -----------
>
>
> On Sunday, January 24, 2016 8:32 PM, Kat <kather...@gmail.com> wrote:
>
>
>
> Hi guys,
>
> I want to copy paste database from one Workbook A to Workbook B. When new 
> row data is added in Workbook A, the excel vba code will compare whether 
> the data is exist in Workbook B. If no, new row data needs to be copied and 
> pasted automatically to last existing row in Workbook B. I've had issue 
> with my code. Can anyone help me have a look? 
>
> Thanks in advance.
>
>
> -- 
> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
> =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
> https://www.facebook.com/discussexcel
>  
> FORUM RULES
>  
> 1) Use concise, accurate thread titles. Poor thread titles, like Please 
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice 
> will not get quick attention or may not be answered.
> 2) Don't post a question in the thread of another member.
> 3) Don't post questions regarding breaking or bypassing any security 
> measure.
> 4) Acknowledge the responses you receive, good or bad.
> 5) Jobs posting is not allowed.
> 6) Sharing copyrighted material and their links is not allowed.
>  
> NOTE : Don't ever post confidential data in a workbook. Forum owners and 
> members are not responsible for any loss.
> --- 
> You received this message because you are subscribed to the Google Groups 
> "MS EXCEL AND VBA MACROS" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to excel-macros...@ googlegroups.com.
> To post to this group, send email to excel-...@googlegroups.com.
>
> Visit this group at https://groups.google.com/group/excel-macros.
> For more options, visit https://groups.google.com/d/optout.
>
>
> -- 
> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
> =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
> https://www.facebook.com/discussexcel
>  
> FORUM RULES
>  
> 1) Use concise, accurate thread titles. Poor thread titles, like Please 
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice 
> will not get quick attention or may not be answered.
> 2) Don't post a question in the thread of another member.
> 3) Don't post questions regarding breaking or bypassing any security 
> measure.
> 4) Acknowledge the responses you receive, good or bad.
> 5) Jobs posting is not allowed.
> 6) Sharing copyrighted material and their links is not allowed.
>  
> NOTE : Don't ever post confidential data in a workbook. Forum owners and 
> members are not responsible for any loss.
> --- 
> You received this message because you are subscribed to the Google Groups 
> "MS EXCEL AND VBA MACROS" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to excel-macros...@googlegroups.com <javascript:>.
> To post to this group, send email to excel-...@googlegroups.com 
> <javascript:>.
> Visit this group at https://groups.google.com/group/excel-macros.
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at https://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

Reply via email to