montecarlo2012
Well-known Member
- Joined
- Jan 26, 2011
- Messages
- 986
- Office Version
- 2010
- Platform
- Windows
Hi everyone.
After searching this forum and elsewhere, I putting some code together, BUT
Error occurred.
The code run until I forced to stop using, {Ctrl + Shift + Esc } and(End Task) in other words go forever.
And I didn’t see any ms comment about the reason
What I am trying to do is to get a “unique array” on sheet 2
and compare this array, Against sheets 3, 4, 5 and 10
sheet 2 is a dynamic array at (“L2: Q2300”) [at the moment]
All the arrays are DYNAMIC also
Located at:
[at the moment the LastRows are the following]
Sheet 5 (“B2:G2300”)
Sheet 3 (“R1:W34200”)
Sheet 4 (“R1:W35000”)
Sheet 10 (“R1:W900”)
Here it is the code:
[Note: my PC or my excel 2010 do not support XL2BB, for that reason I can upload any real good example, SORRY]
Thank you for reading this post, I hope to hear about some help, if it is possible, PLEASE.
After searching this forum and elsewhere, I putting some code together, BUT
Error occurred.
The code run until I forced to stop using, {Ctrl + Shift + Esc } and(End Task) in other words go forever.
And I didn’t see any ms comment about the reason
What I am trying to do is to get a “unique array” on sheet 2
and compare this array, Against sheets 3, 4, 5 and 10
sheet 2 is a dynamic array at (“L2: Q2300”) [at the moment]
All the arrays are DYNAMIC also
Located at:
[at the moment the LastRows are the following]
Sheet 5 (“B2:G2300”)
Sheet 3 (“R1:W34200”)
Sheet 4 (“R1:W35000”)
Sheet 10 (“R1:W900”)
Here it is the code:
VBA Code:
Option Explicit
Dim FoundFlag As Boolean 'indicates found match
Dim lastRow As Long, lastrow3 As Long, lastrow4 As Long, lastrow5 As Long, lastrow10 As Long
Dim arry(1 To 6) As Integer
'find duplicates from sheets 3, 4, 5, and 10 that are also
'in sheet2
Private Sub Montecarlo()
Dim sheeet As Integer
Dim i As Long
Sheets("Sheet2").Activate
Range("L2").End(xlDown).Select
lastRow = ActiveCell.row
Sheets("Sheet3").Activate
Range("R1").End(xlDown).Select
lastrow3 = ActiveCell.row
Sheets("Sheet4").Activate
Range("R1").End(xlDown).Select
lastrow4 = ActiveCell.row
Sheets("Sheet5").Activate
Range("B2").End(xlDown).Select
lastrow5 = ActiveCell.row
Sheets("Sheet10").Activate
Range("R1").End(xlDown).Select
lastrow10 = ActiveCell.row
Application.ScreenUpdating = False
Application.Calculation = xlManual
For sheeet = 3 To 10
Select Case sheeet
Case Is = 3
look4dupes sheeet, 0
Case Is = 4
look4dupes sheeet, 0
Case Is = 5
look4dupes sheeet, -16
Case Is = 10
look4dupes sheeet, 0
Case Else
End Select
Sheets(sheeet).Activate
Next
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic
End Sub
Private Sub look4dupes(shtnum As Integer, offset As Integer)
Dim j As Integer
Dim i As Long, row As Long, fin As Long
Select Case shtnum
Case Is = 3
fin = lastrow3
Case Is = 4
fin = lastrow3
Case Is = 5
fin = lastrow5
Case Is = 10
fin = lastrow10
End Select
For i = 1 To fin
Sheets(shtnum).Activate
For j = 1 To 6
Cells(i, j + 17 + offset).Select
arry(j) = Cells(i, j + 17 + offset)
Next
CheckWith2
Next
End Sub
Private Sub CheckWith2()
Dim row2 As Long
Dim i As Long
Dim temp As Integer
Dim CurCol As Integer
Sheets(2).Activate
For row2 = 2 To lastRow
Cells(row2, 12).Select
If Cells(row2, 12) = arry(1) Then Exit For
Next
If row2 > lastRow Then Exit Sub
temp = row2
For row2 = temp To lastRow
For CurCol = 13 To 12 + 5
Cells(row2, CurCol).Select
If Cells(row2, CurCol) <> arry(CurCol - 11) Then Exit Sub
Next
Exit For
Next
Cells(row2, 18) = "Duplicates "
End Sub
Thank you for reading this post, I hope to hear about some help, if it is possible, PLEASE.