|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
大神们些,小弟初学Excel VBA ,改改代码发现不行啊,需要从一个sheet复制表格到另一个模板sheet,结果在创建了新sheet并命名后就没法运行了,跪求大神解答。代码如下:
Function basic(i As Integer)
Set big_base = Workbooks("业务三部-附件:反洗钱客户身份识别排查表-资产管理事业部 - 20180702")
Set bond_list = big_base.Worksheets("表格1 对非自然人客户的身份识别表")
With bond_list
a = .Range("B" & i)
b = .Range("C" & i)
c = .Range("AA" & i)
d = .Range("F" & i)
e = .Range("E" & i)
f = .Range("G" & i)
g = .Range("F" & i)
h = .Range("Q" & i)
j = .Range("R" & i)
k = .Range("S" & i)
l = .Range("T" & i)
m = .Range("U" & i)
n = .Range("V" & i)
o = .Range("W" & i)
p = .Range("X" & i)
q = .Range("K" & i)
r = .Range("N" & i)
s = .Range("O" & i)
t = .Range("P" & i)
u = .Range("L" & i)
v = .Range("Y" & i)
End With
Sheets.Add After:=Worksheets("福建龙洲运输股份有限公司")
ActiveSheet.Name = a
big_base.Worksheets("福建龙洲运输股份有限公司").Select
Cells.Select
Selection.Copy
Sheets(a).Select
Range("A1").Select
ActiveSheet.Paste
Range("C8:E9") = a
Range("H8:J9") = b
Range("C10:J11") = c
Range("C12:J12") = d
Range("E14:F14") = e
Range("I14:J14") = f
Range("E15:J15") = g
Range("D17:G17") = h
Range("I17:J17") = j
Range("D18:J18") = k
Range("I18:J18") = l
Range("D19:G19") = m
Range("I19:J19") = n
Range("D20:G20") = o
Range("I20:J20") = p
Range("D23:J23") = q
Range("I23:J23") = r
Range("D24:J24") = s
Range("I24:J24") = t
Range("D25:J25") = u
Range("D39:E39") = v
Range("I39:J39") = v
End Function
Sub main_test()
Application.ScreenUpdating = False
For i = 6 To 65
basic (i)
Next
Application.ScreenUpdating = True
End Sub
Sub clear_the_farm()
Application.ScreenUpdating = False
Set test_base = Workbooks("业务三部-附件:反洗钱客户身份识别排查表-资产管理事业部 - 20180702")
MsgBox test_base.Worksheets.Count
Application.DisplayAlerts = False
For i = test_base.Worksheets.Count To 1 Step -1
If test_base.Worksheets(i).Name <> "表格1 对非自然人客户的身份识别表" And test_base.Worksheets(i).Name <> "福建龙洲运输股份有限公司" Then
test_base.Worksheets(i).Delete
End If
Next
Application.DisplayAlerts = True
个人猜测上面黄底纹部分有问题,不过不清楚怎么来~~
|
|