How do I find the last row of data and then use that as a variable

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've been concatenate two columns together and using a defined range, but
when I do this I always wind up with either not enough rows, or to many rows.
I'd like to know how to find the last row of data and then use that in a
macro to only concatenate what I have, is this possible?
 
Good afternoon Lynn Bales


The macro below will find the last row of column a and the last row o
column b, concatenate the two strings in the cell and put the answer i
cell C1.

Sub Test()
a = Application.WorksheetFunction.CountA(Range("A:A"))
b = Cells(a, 1).Value
c = Application.WorksheetFunction.CountA(Range("B:B"))
d = Cells(c, 2).Value
Range("C1").Value = b & d
End Sub

HTH

Dominic
 
If you are trying to find the last used row in a column, use something like
this

Dim rng As Range
Set rng = Range("a65536").End(xlUp)

which will set rng to the very last used cell in col A (assuming you don't
have data all the way down to the last row)
 
Back
Top