Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. x = 1 'first row of data
  2. n = 10 'last row of data, could be 100 for all I know
  3. y = 1 'first column of data
  4. z = 10 'last column of data, could be 100 for all I know
  5.  
  6. Do While x <= n
  7. y = 1 'reset the value of y
  8. Do While y <= z
  9.  
  10. If Workbooks(a).Sheets("Sheet3").cells(x, y) = Workbooks(b).Sheets("Sheet3").cells(x, y) Then
  11. MsgBox "Found the error in row " & x & " and column " & y & ".", VbOKOnly
  12. 'Do something else...
  13. else
  14. End If
  15. y = y + 1 'go to the next column
  16. Loop
  17. x = x + 1 'go to the next row
  18. Loop
  19.  
  20. sub compareandcopy()
  21. dim source as worksheet
  22. dim target as worksheet
  23. set source = workbooks("nameoftemplate").worksheets(3)
  24. set target = workbooks("my wip file").worksheets(3)
  25. dim x as integer
  26. dim y as integer
  27. dim i as integer
  28. source.Activate
  29. x = Selection.Row
  30. target.Activate
  31. y = Selection.Row
  32. for i = 1 to 99
  33. if source.cells(x,i)<>target.cells(y,i) then
  34. target.rows(y+1).insert
  35. source.rows(x).copy target.cells(y+1,1)
  36. exit for
  37. end if
  38. next i
  39. end sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement