Private Sub cmdOUT_Click()
Dim oXL As Object
Dim oBK As Object
Dim oSH As Object
Set oXL = CreateObject("Excel.Application")
Set oBK = oXL.Workbooks.Add
Set oSH = oBK.Worksheets(1)
With MSHFlexGrid1
For r = 0 To .Rows - 1
.Row = r
If r = 0 Then
' OUTPUT YOUR HEADERS
For j = 0 To .Cols - 2
.Col = j
oSH.Cells(1, j + 1).Value = .Text
Next
iROW = iROW + 1
Else
.Col = .Cols - 1
If .Text = 1 Then
For j = 0 To .Cols - 2
.Col = j
oSH.Cells(iROW, j + 1).Value = .Text
Next
iROW = iROW + 1
End If
End If
Next r
End With
oBK.SaveAs ("C:\Documents and Settings\all users\Desktop\Output.xls")
oXL.Quit
End Sub
oSH.Cells(irow, j + 1).Value = .Text
Dim oXL As Object
Dim r As Long
Dim j As Long
Dim irow As Long
Dim oBK As Object
Dim oSH As Object
Set oXL = CreateObject("Excel.Application")
Set oBK = oXL.Workbooks.Add
Set oSH = oBK.Worksheets(1)
With MSHFlexGrid1
For r = 1 To .Rows - 1
.Row = r
If r = 0 Then
' OUTPUT YOUR HEADERS
For j = 0 To .Cols - 2
.Col = j
oSH.Cells(1, j + 1).Value = .Text
Next
irow = irow + 1
Else
.Col = .Cols - 1
If .Text = 1 Then
For j = 0 To .Cols - 2
.Col = j
oSH.Cells(irow, j + 1).Value = .Text
Next
irow = irow + 1
End If
End If
Next r
End With
oBK.SaveAs ("C:\Documents and Settings\all users\Desktop\Output.xls")
oXL.Quit
Remember from the Previous...
You have the Duplicates in the Last Column of you FlexGrid - marked with a value of 1...
Just go through your Grid and export the ones where it is marked..