Need to Redim 2D array after removing blank cells

Arijeet
06-15-2010, 02:56 PM
I have an two dimensional array in which some of the top rows and some of the columns on the left are spaces. I want to remove these blank spaces.

'Code

NRows = GetNumberofRows(TestRng:=Range(Cells(1, 1), Cells.SpecialCells(xlCellTypeLastCell)))
NCols = GetNumberofColumns(TestRng:=Range(Cells(1, 1), Cells.SpecialCells(xlCellTypeLastCell)))

ReDim arr(1 To NRows, 1 To NCols)
For i = 1 To NRows
For j = 1 To NCols
arr(i, j) = TestRng.Cells(i, j)
Next
Next

Here arr contains all cells from (1,1) till last valued cell. In this some of the top rows and columns on the left might be empty and I wish to remove them and Redimension the array and remove the blank rows and columns. Need help please.

bkgashok
06-27-2010, 10:36 AM
hai dear,

from your explanation it is clear that the blank rows are only on the top and the blank columns are on the left of the data.

for this you need to locate the first non blank cell and from its address you can find out the no. of rows and no. of columns and then it is possible to redefine the array.



chek = 1
do while chek = 1

For i = 1 To NRows
For j = 1 To NCols

If Not isblank(arr(i, j)) Then chek = 2

Next
Next
loop

then the array can be re-defined as arry(NRows-i+1,NCols-j+1). if required pls correct the syntax punctuation.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum