Code:
Option Explicit
Sub Button1_Click()
Dim wb As Workbook
Dim ws As Worksheet
Dim FarmerName() As String
Dim PurchasedAmount() As Long
Dim LastRow, NameRow, AmountRow As Long
Dim i, j, k As Integer
i = 1
j = 1
k = 1
Worksheets(1).Activate
Range("F:F").NumberFormat = "General"
LastRow = ActiveSheet.UsedRange.Rows.Count
ReDim FarmerName(1 To LastRow) As String
ReDim PurchasedAmount(1 To LastRow) As Long
For i = 1 To UBound(FarmerName)
FarmerName(i) = Worksheets(1).Range("I" & i).Value
Next i
For j = 1 To UBound(PurchasedAmount)
PurchasedAmount(j) = Worksheets(1).Range("F" & j).Value
Next j
For k = 1 To LastRow Step 1
NameRow = Worksheets(2).Range("I:I").Find(What:=FarmerName(1), SearchDirection:=xlNext, MatchCase:=True).Row
' here the problem arising
AmountRow = Worksheets(2).Range("F:F").Find(What:=PurchasedAmount(1), SearchDirection:=xlNext, MatchCase:=True).Row
If NameRow = AmountRow Then
Worksheets(2).Rows(NameRow).Delete
End If
Next k
'Worksheets(2).Activate
'ActiveSheet.SaveAs Filename:="_revised_" + Replace(Date, "-", ""), FileFormat:=xlCSV, CreateBackup:=True
End Sub
Can anybody help me ? Please
Last edited by a moderator: