Ottsel
Board Regular
- Joined
- Jun 4, 2022
- Messages
- 174
- Office Version
- 365
- Platform
- Windows
I have 2 workbooks total.
Workbook A, which has around 16000 rows + of data. Then Workbook B, which is the one I'm working in has an active directory list.
I have 3 rows of data. Column A, B, C, which should or is listed within both workbooks. I'm using an input box to find the date (where the forth condition comes into play).
Example:
Workbook A & B
Column A: DIS
Column B: ERT
Column C: 1100
Column D: 5/1/2023 / Inputbox answer (dimmed as Ans)
The information is in the same location for both workbooks and I made this macro, so it'll tell me if it can find it within Workbook A. If its unable to, then it'll post a note in column E saying "Unable to locate", so I know to go in and add it before I export my data to workbook A.
The main issue with this code is it is increditly slow. Does anyone here have any suggestions on how to improve its speed? I have 500 rows on Workbook B to check, so it'll take around 20-30 minutes to process.
Workbook A, which has around 16000 rows + of data. Then Workbook B, which is the one I'm working in has an active directory list.
I have 3 rows of data. Column A, B, C, which should or is listed within both workbooks. I'm using an input box to find the date (where the forth condition comes into play).
Example:
Workbook A & B
Column A: DIS
Column B: ERT
Column C: 1100
Column D: 5/1/2023 / Inputbox answer (dimmed as Ans)
The information is in the same location for both workbooks and I made this macro, so it'll tell me if it can find it within Workbook A. If its unable to, then it'll post a note in column E saying "Unable to locate", so I know to go in and add it before I export my data to workbook A.
The main issue with this code is it is increditly slow. Does anyone here have any suggestions on how to improve its speed? I have 500 rows on Workbook B to check, so it'll take around 20-30 minutes to process.
VBA Code:
Private Sub Lot_Blocks_Click()
Dim lastRow As Long
Dim aws As Workbook
Dim ws As Worksheet
Dim i As Integer
Dim Ans As String
Dim msBldr As String
Dim msTract As String
Dim msLot As String
Dim msDate As String
Dim asBldr As String
Dim asTract As String
Dim asLot As String
Dim asDate As String
Dim c As Range
Dim FoundLotBlock As Long
Ans = InputBox("Please input the date." & vbCrLf & _
"Example: 12/1/2017")
If Ans = "" Then
Exit Sub
Else
lastRow = Dirr.Range("A:A").Cells.SpecialCells(xlCellTypeConstants).Count
Set ws = ThisWorkbook.Sheets("Directory")
Set aws = Workbooks.Open(PathSetup.Range("C2"))
For i = 1 To lastRow
FoundLotBlock = 0
For Each c In Columns("A").Cells
msBldr = ws.Cells(i, 1).Value
msTract = ws.Cells(i, 2).Value
msLot = ws.Cells(i, 3).Value
msDate = Ans
asBldr = aws.Sheets("CA Wip Master").Cells(c.Row, 1).Value
asTract = aws.Sheets("CA Wip Master").Cells(c.Row, 2).Value
asLot = aws.Sheets("CA Wip Master").Cells(c.Row, 3).Value
asDate = aws.Sheets("CA Wip Master").Cells(c.Row, 7).Value
If asBldr = msBldr And _
asTract = msTract And _
asLot = msLot And _
asDate = msDate Then
FoundLotBlock = 1
End If
If FoundBlock = 1 Then
GoTo ProceedForward
End If
Next c
ProceedForward:
ws.Activate
ws.Cells(i, 5).Select
If FoundLotBlock = 1 Then
ws.Cells(i, 5).Value = ""
Else
ws.Cells(i, 5).Value = "Action Required."
End If
Next i
End If
MsgBox "Check Complete!", vbOKOnly"
End Sub