ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   How do I find the last row of data and then use that as a variable (https://www.excelbanter.com/new-users-excel/38431-how-do-i-find-last-row-data-then-use-variable.html)

Lynn Bales

How do I find the last row of data and then use that as a variable
 
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?



FSt1

hi,
how are you concatenating now?

regards
FSt1

"Lynn Bales" wrote:

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?



dominicb


Good afternoon Lynn Bales


The macro below will find the last row of column a and the last row of
column b, concatenate the two strings in the cell and put the answer in
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

DominicB


--
dominicb
------------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932
View this thread: http://www.excelforum.com/showthread...hreadid=392490


Duke Carey

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)


"Lynn Bales" wrote:

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?




All times are GMT +1. The time now is 05:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com