Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default MSFlexGrid RemoveItem


Hi all,

I am populating an MSFlexGrid with rows of data manually on click of a
button....so it looks like the following:


Code:
--------------------

PD38 01822-00406 100394788 400 2 50 300 280 76000 600
11 50
PD38 01822-00406 100394791 50 11 20 30 280 4000 100
PD33 01810-10375 100394728 240 11 40 200 280 48000 300
PD33 01722-03509 100393890 210 1 20 160 260 29000 300
2 20
11 10
PD39 01821-00505 100398321 450 2 50 350 300 72000 500
11 50
PD07 01810-04998 100396409 450 11 80 370 240 72000 100
PD30 01722-03012 100390709 210 2 15 195 260 26000 200
PD30 01722-03010 100391991 240 2 10 210 260 32000 500
11 10
12 10

--------------------


As you can see from the above each *PD* can have a group of data. I
want to be able to click on .Col 0 in the MSFlexGrid and delete all
data that is grouped to the *PD* - I've been trying to use RemoveItem
(removes one line) but cant for the life of me think how to loop
through the data set and delete all data that belongs to a particular
*PD*.

Please help.....thanks all.


--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...o&userid=30634
View this thread: http://www.excelforum.com/showthread...hreadid=553978

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default MSFlexGrid RemoveItem


Posting some code to see if it helps or if I'm on the right track;


Code
-------------------

count = 0
For i = frmMain.ProductionGrid.RowSel To frmMain.ProductionGrid.Rows - 1
frmMain.ProductionGrid.row = i
j = i
Do While Not j frmMain.ProductionGrid.Rows - 1

If frmMain.ProductionGrid.TextMatrix(j, 0) = lblMachine1.Caption Or frmMain.ProductionGrid.TextMatrix(j, 0) = "" Then
If Not count = 3 Then
frmMain.ProductionGrid.row = j
''SOME CODE HERE TO DELETE????
count = count + 1
End If
End If
j = j + 1
Loop
Exit For
Next

-------------------


Note: I cant just delete a row within this loop as all row indexes wil
change, so this is where I get a bit stuck.

TI

--
gti_jober
-----------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...fo&userid=3063
View this thread: http://www.excelforum.com/showthread.php?threadid=55397

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default MSFlexGrid RemoveItem


OK its not pretty, but here is my fix:


Code
-------------------

rowSelect = frmMain.ProductionGrid.RowSel
count = 0: machineCount = 0
For i = frmMain.ProductionGrid.RowSel To frmMain.ProductionGrid.Rows - 1
frmMain.ProductionGrid.row = i
j = i
Do While Not j frmMain.ProductionGrid.Rows - 1 And Not machineCount 1

If frmMain.ProductionGrid.TextMatrix(j, 0) = lblMachine1.Caption Then
machineCount = 1
ElseIf frmMain.ProductionGrid.TextMatrix(j, 0) = "" Then
If Not count = 2 Then
frmMain.ProductionGrid.row = j
count = count + 1
End If
End If
j = j + 1
Loop
Exit For
Next

For i = frmMain.ProductionGrid.RowSel To rowSelect Step -1
frmMain.ProductionGrid.row = i
frmMain.ProductionGrid.RemoveItem (frmMain.ProductionGrid.RowSel)
Next

-------------------


if there is a way of cleaning up this code then please let me know

--
gti_jober
-----------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...fo&userid=3063
View this thread: http://www.excelforum.com/showthread.php?threadid=55397

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MSFlexgrid in Excel epkjoha[_2_] Excel Programming 1 May 24th 06 09:59 PM
RemoveItem - ComboBox Mike Excel Programming 1 May 16th 06 04:51 PM
MSFlexGrid Delete Row gti_jobert[_91_] Excel Programming 0 April 26th 06 10:47 AM
MSFlexGrid Jake[_10_] Excel Programming 2 January 19th 05 12:54 AM
MSflexgrid data sirron Excel Programming 1 September 19th 03 09:29 PM


All times are GMT +1. The time now is 04:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"