VBA明细表插入行
- Public Sub ButtunClick(sender As Object, e As SpreadsheetGear.Windows.Controls.ShapeActionEventArgs) Implements Interfaces.IExcelWorkBook.ButtunClick
- ActiveWorkbook.WorkbookSet.GetLock()
- Dim r As Integer = ActiveWorkbook.ActiveWorksheet.WindowInfo.RangeSelection.Row + 1
- Dim rs As Integer = ActiveWorkbook.ActiveWorksheet.Range("T_1406").Row + ActiveWorkbook.ActiveWorksheet.Range("T_1406").RowCount
- Dim c As IRange
- If ActiveWorkbook.ActiveWorksheet.WindowInfo.RangeSelection.Intersect(Range("T_1406")) IsNot Nothing Then
- If e.Shape.Name = "Button 1" Then
- If rs = r Then
- ActiveWorkbook.ActiveWorksheet.Cells("B" & r).Rows.EntireRow.Insert(InsertShiftDirection.Down)
- Range("B" & r + 1 & ":G" & r + 1).Copy(Range("B" & r & ":G" & r))
- For Each c In Range("B" & r + 1 & ":G" & r + 1)
- If c.HasFormula = False Then
- c.ClearContents()
- End If
- Next
- Else
- ActiveWorkbook.ActiveWorksheet.Cells("B" & r + 1).Rows.EntireRow.Insert(InsertShiftDirection.Down)
- Range("B" & r & ":G" & r).Copy(Range("B" & r + 1 & ":G" & r + 1))
- End If
- End If
- Else
- MessageBox.Show("插入行时需要先选中明细表内的单元格后再插入行!")
- End If
- ActiveWorkbook.WorkbookSet.ReleaseLock()
- End Sub '按钮/标签点击事件
复制代码
|
|
hessen