|
发表于 2011-3-28 21:30
|
显示全部楼层
本楼为最佳答案
那就进行了下修改。
这个代码放在SHEET1的模块里
- Option Explicit
- Private Sub Worksheet_SelectionChange(ByVal Target As Range)
- Dim iCurRow As Integer
- Dim iReturn As Integer
- Dim iLeibie As Integer
- Dim iRows As Integer
- iCurRow = Target.Row
- If Target.Count = 1 And Cells(1, Target.Column) = "费用类别" Then
- iReturn = MsgBox("是否选择进行数据转换", 36, "需要转换数据么?")
- If iReturn = 6 Then
- iRows = Range("A65536").End(xlUp).Row
- iLeibie = Target.Column
- Range(Cells(iCurRow, iLeibie), Cells(iRows, iLeibie)).SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=RC[-1]"
- Range(Cells(iCurRow, iLeibie), Cells(iRows, iLeibie)).Copy
- Range(Cells(iCurRow, iLeibie - 1), Cells(iRows, iLeibie - 1)).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
- Range(Cells(iCurRow, iLeibie), Cells(iRows, iLeibie)).Delete xlToLeft
- End If
- End If
- End Sub
复制代码
当你点的在“费用类别”那行的时候提示你需要数据转换否,如果是,则进行数据转换。 |
|