ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help finding the length of two different columns (https://www.excelbanter.com/excel-programming/356251-help-finding-length-two-different-columns.html)

willz99ta via OfficeKB.com

Help finding the length of two different columns
 
Howdy,

Im trying to load two different dynamic arrays with two different column's
data.

One column could be different in size than the other and either column could
be as large as 60000 or as small as one.

What could I use to find the last row of column 1 and then use to find the
last row of column 2. I am trying to fill out the array ranges.

Thanks,

Will

--
Message posted via http://www.officekb.com

Crowbar via OfficeKB.com

Help finding the length of two different columns
 
Considering that all the cells in the column are occupide this will return
the value of the next vacant cell, give it a try, it might be what you need

Use this for column A

For x = 1 to 65536
If sheet1.cells(x, 1).value = "" then
msgbox "" & x
end if
exit for
next

Use this for column B

For y = 1 to 65536
If sheet1.cells(y, 2).value = "" then
msgbox "" & y
end if
exit for
next

It looks for the first instance of nothing and then returns the row number

P.S. On the second line of each script it says Sheet1 change this to Sheets
("YOUR SHEET NAME") ie

For y = 1 to 65536
If sheets("Your Sheet ").cells(y, 2).value = "" then
msgbox "" & y
end if
exit for
next



--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200603/1

JMB

Help finding the length of two different columns
 
Assuming column1 is Column A, and column2 is Column B, to find the last row
of Column A and Column B on Sheet1 (note I am using the code name for the
worksheet - if you want to use the sheet name use Worksheets("YourSheetName")

Sub test()
With Sheet1
MsgBox .Cells(.Rows.Count, 1).End(xlUp).Row
MsgBox .Cells(.Rows.Count, 2).End(xlUp).Row
End With
End Sub

"willz99ta via OfficeKB.com" wrote:

Howdy,

Im trying to load two different dynamic arrays with two different column's
data.

One column could be different in size than the other and either column could
be as large as 60000 or as small as one.

What could I use to find the last row of column 1 and then use to find the
last row of column 2. I am trying to fill out the array ranges.

Thanks,

Will

--
Message posted via http://www.officekb.com


JMB

Help finding the length of two different columns
 
contemplating that you could have data in the very last row of column A or B

Sub test()
With Sheet1
If .Cells(.Rows.Count, 1).Value < "" Then
RowA = .Rows.Count
Else: RowA = .Cells(.Rows.Count, 1).End(xlUp).Row
End If
If .Cells(.Rows.Count, 2).Value < "" Then
RowB = .Rows.Count
Else: RowB = .Cells(.Rows.Count, 2).End(xlUp).Row
End If
End With
End Sub




"willz99ta via OfficeKB.com" wrote:

Howdy,

Im trying to load two different dynamic arrays with two different column's
data.

One column could be different in size than the other and either column could
be as large as 60000 or as small as one.

What could I use to find the last row of column 1 and then use to find the
last row of column 2. I am trying to fill out the array ranges.

Thanks,

Will

--
Message posted via http://www.officekb.com


willz99ta via OfficeKB.com

Help finding the length of two different columns
 
Thank you this code was perfect for what I needed.

Thanks again and keep it up!,
Will

JMB wrote:
contemplating that you could have data in the very last row of column A or B

Sub test()
With Sheet1
If .Cells(.Rows.Count, 1).Value < "" Then
RowA = .Rows.Count
Else: RowA = .Cells(.Rows.Count, 1).End(xlUp).Row
End If
If .Cells(.Rows.Count, 2).Value < "" Then
RowB = .Rows.Count
Else: RowB = .Cells(.Rows.Count, 2).End(xlUp).Row
End If
End With
End Sub

Howdy,

[quoted text clipped - 10 lines]

Will


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200603/1


All times are GMT +1. The time now is 08:31 PM.

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