Please advise why the variable 'lastrow' is storing a value of 0 when there are data up to row 100 in column A
Sub usingFind()
Dim ms As Worksheet
Dim lastrow As Long, i As Long, c
Dim myCell As Range
Set ms = Sheets("mathew")
lastrow = ms.Range("A" & Rows.Count).End(xlUp).Row
x = 2
y = 3
c = ms.Cells(x, y).Value
u = ms.Cells(x, y).Offset(0, -1).Value
If u = "Purchase of goods" Then u1 = "Sales of goods"
If u = "Sales of goods" Then u1 = "Purchase of goods"
Set myCell = ms.Range("A1:A" & 1000).Find(What:=c, LookIn:=xlValues)
If Not myCell Is Nothing And myCell.Offset(0, 1).Value = u1 And _
myCell.Offset(0, 2).Value = c Then
Cells(x, 5).Value = c
Cells(x, 5).Value = myCell.Offset(0, 3).Value
myCell.Offset(0, 4).Value = Cells(x, 1).Value
myCell.Offset(0, 4).Value = Cells(x, 1).Value
End If
Exit Sub
End Sub
Sub usingFind()
Dim ms As Worksheet
Dim lastrow As Long, i As Long, c
Dim myCell As Range
Set ms = Sheets("mathew")
lastrow = ms.Range("A" & Rows.Count).End(xlUp).Row
x = 2
y = 3
c = ms.Cells(x, y).Value
u = ms.Cells(x, y).Offset(0, -1).Value
If u = "Purchase of goods" Then u1 = "Sales of goods"
If u = "Sales of goods" Then u1 = "Purchase of goods"
Set myCell = ms.Range("A1:A" & 1000).Find(What:=c, LookIn:=xlValues)
If Not myCell Is Nothing And myCell.Offset(0, 1).Value = u1 And _
myCell.Offset(0, 2).Value = c Then
Cells(x, 5).Value = c
Cells(x, 5).Value = myCell.Offset(0, 3).Value
myCell.Offset(0, 4).Value = Cells(x, 1).Value
myCell.Offset(0, 4).Value = Cells(x, 1).Value
End If
Exit Sub
End Sub