|
Const firstline = 42
Sub InsertLines()
Dim lastRow As Long
Dim numRows As Long
Dim InsertRows As Long
Dim section As String
Dim rownumbers As String
Dim selectionRow As Long
Dim ItemNum As Long
Application.ScreenUpdating = False
rownumbers = InputBox("请输入您要添加的行数:")
section = "Allrow"
If rownumbers = "" Then
numRows = 0
Else
numRows = rownumbers
End If
Select Case section
Case "Allrow"
lastRow = firstline
Do Until Cells(lastRow, 1).Text = "!@#"
lastRow = lastRow + 1
Loop
Cells(lastRow, 1).Activate
For InsertRows = 1 To numRows
ActiveCell.Offset(-1, 0).Rows("1:1").EntireRow.Copy
Selection.Insert Shift:=xlDown
ActiveCell.Rows.EntireRow.ClearContents
Next InsertRows
Application.CutCopyMode = False
End Select
SetFormulas
ItemNum = firstline
Do Until Cells(ItemNum, 1).Text = "!@#"
Cells(ItemNum, 1).Value = ItemNum - (firstline - 1)
ItemNum = ItemNum + 1
Loop
Cells(lastRow, 1).Select
Application.ScreenUpdating = True
End Sub
'=======================================================
Sub SetFormulas()
Dim cefx As Long
Dim cefy As Long
Dim cefz As Long
Dim celx As Long
Dim cely As Long
Dim celz As Long
Dim listwidth As Long
Dim listlenth As Long
Dim diff As Long
listlenth = 30000
listwidth = 50
cefz = firstline
For cely = cefz To listlenth
If Cells(cely, 1) = "!@#" Then
celz = cely - 1
End If
Next cely
'------------------------------------------------------------
celx = 32
For diff = cefz To celz
Cells(diff, celx).Value = "=SUM(V" & diff & ":AE" & diff & ")"
Next diff
'------------------------------------------------------------
celx = 33
For diff = cefz To celz
Cells(diff, celx).Value = "=IF($U" & diff & "=" & """""" & ",0,IF($U" & diff & "=""01"",1, '汇率表'!$F$3))"
Next diff
'------------------------------------------------------------
celx = 34
For diff = cefz To celz
Cells(diff, celx).Value = "=IF($U" & diff & "=" & """""" & ",0,IF($U" & diff & "= ""01"",1,VLOOKUP($U" & diff & "*1,'汇率表'!$A:$E,5,FALSE)))"
Next diff
celx = 35
For diff = cefz To celz
Cells(diff, celx).Value = "= ROUND(AF" & diff & "*AG" & diff & "*AH" & diff & ",2)"
Next diff
'------------------------------------------------------------
celx = 45
For diff = cefz To celz
Cells(diff, celx).Value = "=SUM(AJ" & diff & ":AR" & diff & ")"
Next diff
'------------------------------------------------------------
celx = 46
For diff = cefz To celz
Cells(diff, celx).Value = "= ROUND(AS" & diff & "*AG" & diff & "*AH" & diff & ",2)"
Next diff
celx = 47
For diff = cefz To celz
Cells(diff, celx).Value = "= AJ" & diff & "+V" & diff
Next diff
celx = 48
For diff = cefz To celz
Cells(diff, celx).Value = "= AF" & diff & "+AS" & diff
Next diff
celx = 49
For diff = cefz To celz
Cells(diff, celx).Value = "= AI" & diff & "+AT" & diff
Next diff
celx = 52
For diff = cefz To celz
Cells(diff, celx).Value = "=IF(AY" & diff & "-AW" & diff & ">0,0,AY" & diff & "-AW" & diff & ")"
Next diff
celx = 76
For diff = cefz To celz
Cells(diff, celx).Value = "= IF(ROUND(AV" & diff & "-SUM(BQ" & diff & ":BW" & diff & "),0)=0,""一致"",""不一致"")"
Next diff
Cells(firstline - 1, 35).Value = "=SUM(AI" & firstline & ":AI" & celz & ")"
Cells(firstline - 1, 46).Value = "=SUM(AT" & firstline & ":AT" & celz & ")"
Cells(firstline - 1, 49).Value = "=SUM(AW" & firstline & ":AW" & celz & ")"
Cells(firstline - 1, 52).Value = "=SUM(AZ" & firstline & ":AZ" & celz & ")"
End Sub |
|