Home
Forums
New posts
Search forums
Articles
Latest reviews
Search resources
Members
Current visitors
Newsgroups
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
Newsgroups
Microsoft Excel
Microsoft Excel Programming
VBA comparing sheets and cells
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Vacuum Sealed, post: 14136160"] Hi Maurice This is not the most prettiest of codes, but it works for what you want. Someone else may have a cleaner code to use. Sub Compare() Dim sSht As Worksheet, tSht As Worksheet Dim i As Integer, j As Integer For j = 2 To 100 'Resize to suit Set tSht = Sheets("Sheet1") For i = 2 To 100 'Resize to suit Set sSht = Sheets("Sheet2") If sSht.Range("A" & i) = tSht.Range("A" & j) Then sSht.Range("A" & i).Resize(i, 30).Copy 'This copies A to AE tSht.Activate tSht.Range("A" & j).Select ActiveSheet.Paste End If Next i Range("A1").Select Next j sSht.Activate Application.CutCopyMode = False Range("A1").Select End Sub I tried to shorten the Copy/Paste to this: sSht.Range("A" & i).Resize(i, 30).Copy (tSht.Range("A" & j)) But it did not like it and halted on it so I stepped through it individually as above. HTH Mick. [/QUOTE]
Verification
Post reply
Home
Forums
Newsgroups
Microsoft Excel
Microsoft Excel Programming
VBA comparing sheets and cells
Top