'MsFlexGrid操作函数'合并列
Public Function MergeCol(GridObj As Object, ByVal StartCol As Long, ByVal EndCol As Long, ByVal ColValue As String, ByVal CurrentRow As Long) As Boolean
If StartCol > EndCol Or StartCol > GridObj.Cols Or CurrentRow > GridObj.Rows Then
    MsgBox "对不起,行列设置错误!", vbOKOnly, App.Title
    MergeCol = False
    Exit Function
End IfFor I = StartCol To EndCol
GridObj.MergeCol(I) = True
GridObj.TextArray(faIndex(GridObj, CurrentRow, I)) = ColValue
GridObj.ColAlignment(I) = flexAlignCenterCenter
Next I
GridObj.MergeRow(CurrentRow) = TrueMergeCol = TrueEnd Function
'合并行
Public Function MergeRow(GridObj As Object, ByVal StartRow As Long, ByVal EndRow As Long, ByVal RowValue As String, ByVal CurrentCol As Long) As Boolean
If StartRow > EndRow Or StartRow > GridObj.Rows Or CurrentCol > GridObj.Cols Then
    MsgBox "对不起,行列设置错误!", vbOKOnly, App.Title
    MergeRow = False
    Exit Function
End IfFor I = StartRow To EndRow
GridObj.MergeRow(I) = True
GridObj.TextArray(faIndex(GridObj, I, CurrentCol)) = RowValue
GridObj.ColAlignment(CurrentCol) = flexAlignCenterCenterNext I
GridObj.MergeCol(CurrentCol) = True
MergeRow = TrueEnd Function'转换索引
Public Function faIndex(GridObj As Object, ByVal row As Integer, ByVal col As Integer) As Long
If row > GridObj.Rows Or row < 0 Or col > GridObj.Cols Or col < 0 Then
    MsgBox "对不起,行列设置错误!", vbOKOnly, App.Title
    faIndex = -1
    
    Exit Function
End IffaIndex = row * GridObj.Cols + colEnd Function
'插入行
Public Function SetItem(GridObj As Object, ByVal row As Integer, ByVal col As Integer, ByVal SetValue As String) As Boolean
If row > GridObj.Rows Or row < 0 Or col > GridObj.Cols Or col < 0 Then
    MsgBox "对不起,行列设置错误!", vbOKOnly, App.Title
    SetItem = False
    Exit Function
End If
    GridObj.TextArray(faIndex(GridObj, row, col)) = SetValue
    
    SetItem = True
End Function'得到单元格值
Public Function GetItem(GridObj As Object, ByVal row As Integer, ByVal col As Integer) As StringIf row > GridObj.Rows Or row < 0 Or col > GridObj.Cols Or col < 0 Then
    MsgBox "对不起,行列设置错误!", vbOKOnly, App.Title
    GetItem = ""
    Exit Function
End If
    GetItem = GridObj.TextArray(faIndex(GridObj, row, col))
End Function这是我以前写的几个函数,不知能不能帮上你, 我弄Excel时间挺长,有什么问题可以给我发[email protected]