Consider the below matrix:
Col1 Col2 Col3 Col4 Col5 Col6 Col7
R1 x x x
R2 x x x
R3 x
R4 x x x
R5 x
Now using VBScript or ADO whichever will it be possible to find the distance of the last element of each row? Defination of distance distance is nothing but the count of number of cells after which the last element is placed in the given matrix. for e.g say –
-
Dist(R1)=5
-
Dist(R4)=4 like wise
I tried the below:
Option Explicit
Dim ArrayListTaskDetails : Set ArrayListTaskDetails = CreateObject("System.Collections.ArrayList")
Dim i,colcount
i=2
Do while i < = objExcel1.Application.WorksheetFunction.CountA(ob.Rows(1))
colcount=objExcel1.Application.WorksheetFunction.CountA(ob.Rows(i))
ArrayListTaskDetails.Add(colcount)
i=i+1
Loop
ArrayListTaskDetails.Sort()
i=ArrayListTaskDetails.Count
MsgBox("HighestColumnNumner:" & ArrayListTaskDetails(i-1))
But it is not working,as couldn’t handle the in between blanks.
Thnaks,
Another way… Using Formulas in VBSCRIPT
Screenshot
Followup
As per the request
More Followup