Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi.
I want to read all sheet from excel to my program. As i understand, i can use cell(i,j), but for this i need number of rows and columns, how can i get it? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Assuming data starts in A1 and there are no blank rows or columns embedded
Dim v() as Variant set rng = Activesheet.Range("A1").CurrentRegion numrows = rng.rows.count numcols = rng.columns.count redim v(1 to numrows, 1 to numcols) for i = numrows for j = numcols v(i,j) = rng(i,j).value Next Next or for i = numrows for j = numcols val(i,j) = cells(i,j).Value next Next -- Regards, Tom Ogilvy "Artem Omelianchuk" wrote in message ... Hi. I want to read all sheet from excel to my program. As i understand, i can use cell(i,j), but for this i need number of rows and columns, how can i get it? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Check the UsedRange property of the Worksheet object. And, you don't
have to go through every cell one at a time. The following transfers the complete worksheet into a 2D matrix in the variant x. Sub testIt() Dim x x = ActiveSheet.UsedRange.Value End Sub -- Regards, Tushar Mehta www.tushar-mehta.com Excel, PowerPoint, and VBA add-ins, tutorials Custom MS Office productivity solutions In article , says... Hi. I want to read all sheet from excel to my program. As i understand, i can use cell(i,j), but for this i need number of rows and columns, how can i get it? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you mean the number of used cells on the worksheet:
RowsUsed = Sheets("SheetName").UsedRange.Rows.Count ColumnsUsed = Sheets("SheetName").UsedRange.Columns.Count "Artem Omelianchuk" wrote: Hi. I want to read all sheet from excel to my program. As i understand, i can use cell(i,j), but for this i need number of rows and columns, how can i get it? |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Dim ws As Worksheet, nColsRows() As Integer, i As Integer i = 0 Const FST_ROW = 0 Const ROW_CNT = 1 Const FST_COL = 2 Const COL_CNT = 3 For Each ws In Worksheets With ws.UsedRange ReDim Preserve nColsRows(3, i) nColsRows(FST_ROW, i) = .Row nColsRows(ROW_CNT, i) = .Row + .Rows.Count - 1 nColsRows(FST_COL, i) = .Column nColsRows(COL_CNT, i) = .Column + .Columns.Count - 1 i = i + 1 End With Nex -- SkipVough ----------------------------------------------------------------------- SkipVought's Profile: http://www.msusenet.com/member.php?userid=198 View this thread: http://www.msusenet.com/t-187051429 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Number of rows/columns occupied | Excel Worksheet Functions | |||
limited columns and rows number | New Users to Excel | |||
Customize number of rows and columns | Excel Discussion (Misc queries) | |||
Set number of columns/rows? | Excel Discussion (Misc queries) | |||
number of columns/rows | Excel Discussion (Misc queries) |