Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
pre-set the length of columns | New Users to Excel | |||
Finding a string of unknown length in a string of unknown length, Help! | Excel Discussion (Misc queries) | |||
Finding cells of different string length. | Excel Discussion (Misc queries) | |||
Max/Min for variable length columns | Excel Programming | |||
different length columns | Excel Discussion (Misc queries) |