ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Length of Used Column (https://www.excelbanter.com/excel-programming/280140-length-used-column.html)

Alec

Length of Used Column
 
Can anyone tell me why the following sometimes works,
depending on cell contents.

Range("A6").Value = Range(Range("C1").End(xlDown)).Row

For a used range, eg "C1:C36" I want to put the values 1
to 36 in the range "B1:B36" automatically, for this I need
to find the last used cell, eg "C36". The range length
varies, hence the use of the above function.

Thanks
Alec

Tom Ogilvy

Length of Used Column
 
That never works because the syntax is incorrect

Sub Tester9()
h = Range("C65536").End(xlUp).Row
Range("B1") = 1
Range("B2") = 2
Range("B1:B2").AutoFill _
Destination:=Range("B1:B" & h), _
Type:=xlFillDefault

End Sub

--
Regards,
Tom Ogilvy

"Alec" wrote in message
...
Can anyone tell me why the following sometimes works,
depending on cell contents.

Range("A6").Value = Range(Range("C1").End(xlDown)).Row

For a used range, eg "C1:C36" I want to put the values 1
to 36 in the range "B1:B36" automatically, for this I need
to find the last used cell, eg "C36". The range length
varies, hence the use of the above function.

Thanks
Alec




Alec

Length of Used Column
 
Thanks Tom
That routine works great.



-----Original Message-----
That never works because the syntax is incorrect

Sub Tester9()
h = Range("C65536").End(xlUp).Row
Range("B1") = 1
Range("B2") = 2
Range("B1:B2").AutoFill _
Destination:=Range("B1:B" & h), _
Type:=xlFillDefault

End Sub

--
Regards,
Tom Ogilvy

"Alec" wrote in

message
...
Can anyone tell me why the following sometimes works,
depending on cell contents.

Range("A6").Value = Range(Range("C1").End(xlDown)).Row

For a used range, eg "C1:C36" I want to put the values 1
to 36 in the range "B1:B36" automatically, for this I

need
to find the last used cell, eg "C36". The range length
varies, hence the use of the above function.

Thanks
Alec



.



All times are GMT +1. The time now is 10:42 AM.

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