将单元格中的文本公式内容写入计算单元格
需求:将单元格中的文本公式内容写入计算单元格的VBA
写法:这里只提供写法,不展示效果了,可作为VBA的参考
- Public Sub ButtunClick(sender As Object,e As SpreadsheetGear.Windows.Controls.ShapeActionEventArgs)
- If e.Shape.Name = "执行计算" Then
- Dim lastRow As Long
- Dim destCol As Long
- Dim srcCol As Long
- Dim i As Long
- Dim Cells As IRange = ActiveWorkbook.ActiveWorksheet.Cells
- '确定源和目标列
- srcCol = 12 'L列
- destCol = 7 'G列
- lastRow = Range("F_5245").RowCount + 14
- For i = 15 To lastRow
- If Cells(i, srcCol).Value <> "" Then
- Cells(i, destCol).Formula = "=" & Cells(i, srcCol).Value
- Else
- If MessageBox.Show("单元格" & Cells(i, srcCol).Address & "的值为空!是否继续计算?确定继续,取消退出!", "公式计算提醒", MessageBoxButton.OKCancel) = MessageBoxResult.Cancel Then
- Exit For
- End If
- End If
- Next i
- End If
- End Sub'按钮/标签点击事件
复制代码
|
|
hessen