To change Columns(4).Rows.Count

G

Guest

Hi guys I would like to know how to sustitute the "Columns(4).Rows.Count"
statement for something more efficient, the Idea is to know in wich cell I
find the last record, instead off read all the column , there are no empty
cells in between, I had to assign Long to "i" because I got an overflow with
byte or integer.

Thanks


Dim i As Long, j As Integer

For j = 1 To 10
For i = 1 To Columns(4).Rows.Count
If Cells(i, 4) = Cells(j, 1) Then
Cells(i, 5) = Range("Especias")(j, 2).Value
End If
Next i
Next j

End Sub
 
G

Guest

You can get the last row for that column with
lr4 = Cells(rows.Count, 4).End(xlUp).Row
And then just plug it into
For i = 1 To lr4
The way you have it would equal 1 To 65356.
With the lr4 it will only go to the last row in that column with data.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top