Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Ubound(x) gives rows in a range-array - but what about columns ?
Hi experts:
Lets say i got: ActiveSheet.UsedRange.Select x = Selection r=Ubound(x) ' numbers of rows problem is how do i get columns ? i tryed c=x.columns c=x.columns.count c=Range(x).columns nothing works grrrrrr Help pls. :-) |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Ubound(x) gives rows in a range-array - but what about columns ?
One way:
Sub GetRowsAndColums() Dim x As Range Dim rRow Dim cCol ActiveSheet.UsedRange.Select Set x = Selection cCol = x.Columns.Count rRow = x.Rows.Count MsgBox rRow & " " & cCol End Sub Regards Trevor "excelent" wrote in message ... Hi experts: Lets say i got: ActiveSheet.UsedRange.Select x = Selection r=Ubound(x) ' numbers of rows problem is how do i get columns ? i tryed c=x.columns c=x.columns.count c=Range(x).columns nothing works grrrrrr Help pls. :-) |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Ubound(x) gives rows in a range-array - but what about columns ?
It is good practice to always declare your variables and
to use the default properties of objects. '--------------- Sub MNO() Dim x As Variant Dim Rw As Long Dim Col As Long 'Transfer range values as a 2 dimensional array to the variant variable. x = Selection.Value Rw = UBound(x, 1) Col = UBound(x, 2) MsgBox Rw & " " & Col 'Assigns object reference to the variable. 'This works for a variant or range object variable. Set x = Selection Rw = x.Rows.Count Col = x.Columns.Count MsgBox Rw & " " & Col End Sub -- Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware "excelent" wrote in message Hi experts: Lets say i got: ActiveSheet.UsedRange.Select x = Selection r=Ubound(x) ' numbers of rows problem is how do i get columns ? i tryed c=x.columns c=x.columns.count c=Range(x).columns nothing works grrrrrr Help pls. :-) |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Ubound(x) gives rows in a range-array - but what about columns
ok Trevor ty for reply, ill try that
|
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Ubound(x) gives rows in a range-array - but what about columns
y ur right bout that Jim ill try to remember :-)
tks for reply, hope i got it now. |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Ubound(x) gives rows in a range-array - but what about columns ?
One more working with the array:
Dim x As Variant x = ActiveSheet.UsedRange.Value MsgBox UBound(x, 1) & vbLf & UBound(x, 2) (rows, then columns) excelent wrote: Hi experts: Lets say i got: ActiveSheet.UsedRange.Select x = Selection r=Ubound(x) ' numbers of rows problem is how do i get columns ? i tryed c=x.columns c=x.columns.count c=Range(x).columns nothing works grrrrrr Help pls. :-) -- Dave Peterson |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Ubound(x) gives rows in a range-array - but what about columns
yep works too
tks. Dave |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I name rows and columns in an array | New Users to Excel | |||
Array Ubound | Excel Programming | |||
UBound of multi-dimensional array? | Excel Programming | |||
Handling ubound on an uninitialised array | Excel Programming |