ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Msflexgrid Coldata (https://www.excelbanter.com/excel-programming/364674-msflexgrid-coldata.html)

vishal

Msflexgrid Coldata
 
Hi All,
I am using MSFlexgrid control in one of my userform of Excel.
I want to get data of a particular column (e.g. Column # 2) and store it in
an array. Is there any simple way of doing it instead of using loop (for,
while)?
Currently I am doing following way:

Dim tempdata()
Redim tempdata (msflexgrid1.rows)

for i = 0 to msflexgrid1.rows-1
tempdata(i) = msflexgrid1.textmatrix(i,1)
next i

But if I try to do the same with following code then it gives error.
Dim tempdata()
tempdata = msflexgrid1.coldata(1)

This gives a compile error! Could you please guide me for this?

Second-
Using for loop method, I am able to write complete data to the array but
while doing following
Range(clmname & temprow).Resize(UBound(tempdata), 1).Value = tempdata
It only writes the first data!
Could you help me for this?

Regards,
Vishal.

Tom Ogilvy

Msflexgrid Coldata
 
I have not idea about the capabilities of the msflexgrid control. for your
other question:

Range(clmname & temprow).Resize(UBound( _
tempdata), 1).Value = Application.Transpose(tempdata)

--
Regards,
Tom Ogilvy



"Vishal" wrote:

Hi All,
I am using MSFlexgrid control in one of my userform of Excel.
I want to get data of a particular column (e.g. Column # 2) and store it in
an array. Is there any simple way of doing it instead of using loop (for,
while)?
Currently I am doing following way:

Dim tempdata()
Redim tempdata (msflexgrid1.rows)

for i = 0 to msflexgrid1.rows-1
tempdata(i) = msflexgrid1.textmatrix(i,1)
next i

But if I try to do the same with following code then it gives error.
Dim tempdata()
tempdata = msflexgrid1.coldata(1)

This gives a compile error! Could you please guide me for this?

Second-
Using for loop method, I am able to write complete data to the array but
while doing following
Range(clmname & temprow).Resize(UBound(tempdata), 1).Value = tempdata
It only writes the first data!
Could you help me for this?

Regards,
Vishal.



All times are GMT +1. The time now is 12:31 AM.

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