Vba 我的标题一直消失,它没有固定到正确的行
此页面应显示所选保单编号/计划详细信息。像这样的不同组件。但这取决于保单数量。有些可能有1个,有些可能不止1个。我根据每个策略编号的组件数量,设法使计划/组件正常工作。但“我的资金投资”标题和“组件”标题无法根据保单编号显示值 显示问题: 我尝试做基金投资价值,但我的组件标题将消失。如果不是,我的组件值将与投资基金标题一起放置。怎么了 代码:Vba 我的标题一直消失,它没有固定到正确的行,vba,excel,header,Vba,Excel,Header,此页面应显示所选保单编号/计划详细信息。像这样的不同组件。但这取决于保单数量。有些可能有1个,有些可能不止1个。我根据每个策略编号的组件数量,设法使计划/组件正常工作。但“我的资金投资”标题和“组件”标题无法根据保单编号显示值 显示问题: 我尝试做基金投资价值,但我的组件标题将消失。如果不是,我的组件值将与投资基金标题一起放置。怎么了 代码: Sub LinkName() Dim i As Long, k As Long, b As Long, c As Long, f As Long
Sub LinkName()
Dim i As Long, k As Long, b As Long, c As Long, f As Long 'For loop variable
Dim ShtUsedRange, ShtUsedRangeCol
Dim rw As Variant
Dim policynum As Variant
Dim lookup_range As Range
Dim box As Variant
Dim counter As Long, DetailsCounter As Long, FundInfoCounter As Long, FundAllocationCounter As Long
Dim a As Long, d As Long, e As Long, p As Long, m As Long
ShtUsedRange = ActiveSheet.UsedRange.Rows.Count
'Count the used rows in the Activesheet
ShtUsedRangeCol = ActiveSheet.UsedRange.Columns.Count
'Count the used Column in the Activesheet
rw = ActiveCell.Row
'Row number of the Selected Cell
policynum = ActiveSheet.Cells(rw, 3).Value
'policynum of the row selected
Set lookup_range = ThisWorkbook.Sheets("PolicyComponents").Range("c4:iv30000")
'set the range of the Policy details to search from
box = Application.VLookup(policynum, lookup_range, 1, False)
'to match the policy num to the policy details
counter = ThisWorkbook.Sheets("PolicyComponents").UsedRange.Rows.Count
'MsgBox counter
k = 16
Do While (ThisWorkbook.Sheets("Policy Viewer").Range("B" & k) <> "")
ThisWorkbook.Sheets("Policy Viewer").Rows(k & ":" & k).Delete
Loop
'delete the previous set of components
a = 16 'Start of Plan/Component
d = 21 'Start of Funds Invested
'Based On PolicyComponents Table
For i = 4 To counter Step 1
If ThisWorkbook.Sheets("PolicyComponents").Cells(i, 3).Value = box Then
ThisWorkbook.Sheets("Policy Viewer").Cells(a, 2).Value = ThisWorkbook.Sheets("PolicyComponents").Cells(i, 4).Value
'Policy Components
ThisWorkbook.Sheets("Policy Viewer").Cells(a, 3).Value = ThisWorkbook.Sheets("PolicyComponents").Cells(i, 5).Value
'Status
ThisWorkbook.Sheets("Policy Viewer").Cells(a, 4).Value = ThisWorkbook.Sheets("PolicyComponents").Cells(i, 6).Value
'Life Assured
ThisWorkbook.Sheets("Policy Viewer").Cells(a, 5).Value = ThisWorkbook.Sheets("PolicyComponents").Cells(i, 7).Value
'Benefit Amt/ Sum Assured
ThisWorkbook.Sheets("Policy Viewer").Cells(a, 6).Value = ThisWorkbook.Sheets("PolicyComponents").Cells(i, 8).Value
'Premium
ThisWorkbook.Sheets("Policy Viewer").Cells(a, 7).Value = ThisWorkbook.Sheets("PolicyComponents").Cells(i, 9).Value
'Single Premium
ThisWorkbook.Sheets("Policy Viewer").Cells(a, 8).Value = ThisWorkbook.Sheets("PolicyComponents").Cells(i, 10).Value
'Premium Cessation Date
ThisWorkbook.Sheets("Policy Viewer").Cells(a, 9).Value = ThisWorkbook.Sheets("PolicyComponents").Cells(i, 11).Value
'Risk Commencement Date
ThisWorkbook.Sheets("Policy Viewer").Cells(a, 10).Value = ThisWorkbook.Sheets("PolicyComponents").Cells(i, 12).Value
'Risk Cessation Date
ThisWorkbook.Sheets("Policy Viewer").Cells(a, 11).Value = ThisWorkbook.Sheets("PolicyComponents").Cells(i, 13).Value
'Est. Total Paid
ThisWorkbook.Sheets("Policy Viewer").Rows(a + 1 & ":" & a + 1).Insert
'insert blank lines
a = a + 1
End If
Next i
'End of Plan/Component Table
'For Policy Details
DetailsCounter = ThisWorkbook.Sheets("PolicyDetails").UsedRange.Rows.Count
For b = 4 To DetailsCounter Step 1
If ThisWorkbook.Sheets("PolicyDetails").Cells(b, 3).Value = box Then
'POLICY VIEWER
ThisWorkbook.Sheets("Policy Viewer").Cells(2, 3).Value = ThisWorkbook.Sheets("PolicyDetails").Cells(b, 1).Value
'Policy Owner Name
ThisWorkbook.Sheets("Policy Viewer").Cells(3, 3).Value = ThisWorkbook.Sheets("PolicyDetails").Cells(b, 2).Value
'Plan Type
ThisWorkbook.Sheets("Policy Viewer").Cells(4, 3).Value = ThisWorkbook.Sheets("PolicyDetails").Cells(b, 3).Value
'Policy Num***
ThisWorkbook.Sheets("Policy Viewer").Cells(5, 3).Value = ThisWorkbook.Sheets("PolicyDetails").Cells(b, 4).Value
'Policy Status
ThisWorkbook.Sheets("Policy Viewer").Cells(6, 3).Value = ThisWorkbook.Sheets("PolicyDetails").Cells(b, 5).Value
'Payment Method
ThisWorkbook.Sheets("Policy Viewer").Cells(7, 3).Value = ThisWorkbook.Sheets("PolicyDetails").Cells(b, 6).Value
'Paid-To-Date
ThisWorkbook.Sheets("Policy Viewer").Cells(8, 3).Value = ThisWorkbook.Sheets("PolicyDetails").Cells(b, 7).Value
'Frequency
ThisWorkbook.Sheets("Policy Viewer").Cells(9, 3).Value = ThisWorkbook.Sheets("PolicyDetails").Cells(b, 8).Value
'Premium $
ThisWorkbook.Sheets("Policy Viewer").Cells(10, 3).Value = ThisWorkbook.Sheets("PolicyDetails").Cells(b, 9).Value
'Amt In Suspense
ThisWorkbook.Sheets("Policy Viewer").Cells(11, 3).Value = ThisWorkbook.Sheets("PolicyDetails").Cells(b, 16).Value
'Servicing Agent
ThisWorkbook.Sheets("Policy Viewer").Cells(7, 9).Value = ThisWorkbook.Sheets("PolicyDetails").Cells(b, 10).Value
'Life Assured
ThisWorkbook.Sheets("Policy Viewer").Cells(8, 9).Value = ThisWorkbook.Sheets("PolicyDetails").Cells(b, 11).Value
'Joint Life Assured
ThisWorkbook.Sheets("Policy Viewer").Cells(9, 9).Value = ThisWorkbook.Sheets("PolicyDetails").Cells(b, 12).Value
'2nd Joint Life Assured
ThisWorkbook.Sheets("Policy Viewer").Cells(10, 9).Value = ThisWorkbook.Sheets("PolicyDetails").Cells(b, 13).Value
'Joint PolicyOwner
ThisWorkbook.Sheets("Policy Viewer").Cells(11, 9).Value = ThisWorkbook.Sheets("PolicyDetails").Cells(b, 14).Value
'Assignees
ThisWorkbook.Sheets("Policy Viewer").Cells(12, 9).Value = ThisWorkbook.Sheets("PolicyDetails").Cells(b, 15).Value
'Trustees
ThisWorkbook.Sheets("Policy Viewer").Cells(2, 9).Value = ThisWorkbook.Sheets("PolicyValues").Cells(b, 4).Value
'Est ILP Surrender Value
ThisWorkbook.Sheets("Policy Viewer").Cells(3, 9).Value = ThisWorkbook.Sheets("PolicyValues").Cells(b, 5).Value
'Gross Surrender Value
ThisWorkbook.Sheets("Policy Viewer").Cells(4, 9).Value = ThisWorkbook.Sheets("PolicyValues").Cells(b, 6).Value
'Gross Cash Bonus
ThisWorkbook.Sheets("Policy Viewer").Cells(5, 9).Value = ThisWorkbook.Sheets("PolicyValues").Cells(b, 7).Value
'Total Cashback
ThisWorkbook.Sheets("Policy Viewer").Cells(6, 9).Value = ThisWorkbook.Sheets("PolicyValues").Cells(b, 8).Value
'Est Total Paid
End If
Next b
'End of Policy Details (B2:I12)
=====================================================================
xxxxxxxxxxxxxxxxxxxxxI think problem lies herexxxxxxxxxxxxxxxxxxxxxxx
=====================================================================
p = 21
'For Funds Invested table
Do While (ThisWorkbook.Sheets("Policy Viewer").Range("B" & p) <> "")
ThisWorkbook.Sheets("Policy Viewer").Rows(p & ":" & p).Delete
Loop
FundInfoCounter = ThisWorkbook.Sheets("Fund Information").UsedRange.Rows.Count
For c = 4 To FundInfoCounter Step 1
If ThisWorkbook.Sheets("Fund Information").Cells(c, 3).Value = box Then
ThisWorkbook.Sheets("Policy Viewer").Cells(d, 2).Value = ThisWorkbook.Sheets("Fund Information").Cells(c, 4).Value
'Funds Invested
ThisWorkbook.Sheets("Policy Viewer").Cells(d, 3).Value = ThisWorkbook.Sheets("Fund Information").Cells(c, 5).Value
'Unit Balance
ThisWorkbook.Sheets("Policy Viewer").Cells(d, 4).Value = ThisWorkbook.Sheets("Fund Information").Cells(c, 6).Value
'Bid Price
ThisWorkbook.Sheets("Policy Viewer").Cells(d, 5).Value = ThisWorkbook.Sheets("Fund Information").Cells(c, 7).Value
'Unit Value
ThisWorkbook.Sheets("Policy Viewer").Cells(d, 6).Value = ThisWorkbook.Sheets("Fund Information").Cells(c, 8).Value
'Unit Value as at
ThisWorkbook.Sheets("Policy Viewer").Rows(d + 1 & ":" & d + 1).Insert
'insert blank lines
d = d + 1
End If
Next c
'End of Fund Invested Table
m = p + 3
e = 24 ' start of component
'For Components Table
Do While (ThisWorkbook.Sheets("Policy Viewer").Range("B" & m) <> "")
ThisWorkbook.Sheets("Policy Viewer").Rows(m & ":" & m).Delete
Loop
FundAllocationCounter = ThisWorkbook.Sheets("Fund Allocation").UsedRange.Rows.Count
For f = 4 To FundAllocationCounter Step 1
If ThisWorkbook.Sheets("Fund Allocation").Cells(f, 3).Value = box Then
ThisWorkbook.Sheets("Policy Viewer").Cells(e, 2).Value = ThisWorkbook.Sheets("Fund Allocation").Cells(f, 4).Value
'Component
ThisWorkbook.Sheets("Policy Viewer").Cells(e, 3).Value = ThisWorkbook.Sheets("Fund Allocation").Cells(f, 5).Value
'Fund Invested
ThisWorkbook.Sheets("Policy Viewer").Cells(e, 6).Value = ThisWorkbook.Sheets("Fund Allocation").Cells(f, 6).Value
'Percentage
ThisWorkbook.Sheets("Policy Viewer").Rows(e + 1 & ":" & e + 1).Insert
'insert blank lines
End If
Next f
'End of Components Table
=====================================================================
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
=====================================================================
End Sub
sublinkname()
对于循环变量,Dim i为Long,k为Long,b为Long,c为Long,f为Long
暗ShtUsedRange,ShtUsedRangeCol
变光rw
Dim policynum作为变量
Dim查找范围作为范围
变光盒作为变型
暗显计数器为长,详细信息计数器为长,基金信息计数器为长,基金分配计数器为长
将a变长,d变长,e变长,p变长,m变长
ShtUsedRange=ActiveSheet.UsedRange.Rows.Count
'计算Activesheet中使用的行数
ShtUsedRangeCol=ActiveSheet.UsedRange.Columns.Count
'统计Activesheet中已使用的列
rw=ActiveCell.Row
'所选单元格的行号
policynum=ActiveSheet.Cells(rw,3).Value
'所选行的policynum
设置查找范围=此工作簿.Sheets(“PolicyComponents”).range(“c4:iv30000”)
'设置要从中搜索的策略详细信息的范围
box=Application.VLookup(policynum,lookup\u range,1,False)
'将策略编号与策略详细信息匹配
计数器=ThisWorkbook.Sheets(“PolicyComponents”).UsedRange.Rows.Count
'MsgBox计数器
k=16
Do While(ThisWorkbook.Sheets(“策略查看器”).Range(“B”和k)”)
ThisWorkbook.Sheets(“策略查看器”).行(k&“:”&k).删除
环
'删除上一组组件
a=16'平面图/部件开始
d=21'投资基金的开始
'基于PolicyComponents表
如果i=4,则计数器执行步骤1
如果此工作簿.Sheets(“PolicyComponents”).Cells(i,3).Value=box,则
ThisWorkbook.Sheets(“策略查看器”).Cells(a,2).Value=ThisWorkbook.Sheets(“策略组件”).Cells(i,4).Value
“政策组成部分
ThisWorkbook.Sheets(“策略查看器”).Cells(a,3).Value=ThisWorkbook.Sheets(“策略组件”).Cells(i,5).Value
"地位",
ThisWorkbook.Sheets(“策略查看器”).Cells(a,4).Value=ThisWorkbook.Sheets(“策略组件”).Cells(i,6).Value
"生命有保障",
ThisWorkbook.Sheets(“策略查看器”).Cells(a,5).Value=ThisWorkbook.Sheets(“策略组件”).Cells(i,7).Value
“福利金额/保证金额
ThisWorkbook.Sheets(“策略查看器”).Cells(a,6).Value=ThisWorkbook.Sheets(“策略组件”).Cells(i,8).Value
“保险费
ThisWorkbook.Sheets(“策略查看器”).Cells(a,7).Value=ThisWorkbook.Sheets(“策略组件”).Cells(i,9).Value
“单一溢价
ThisWorkbook.Sheets(“策略查看器”).Cells(a,8).Value=ThisWorkbook.Sheets(“策略组件”).Cells(i,10).Value
“保费终止日期”
ThisWorkbook.Sheets(“策略查看器”).Cells(a,9).Value=ThisWorkbook.Sheets(“策略组件”).Cells(i,11).Value
“风险开始日期”
ThisWorkbook.Sheets(“策略查看器”).Cells(a,10).Value=ThisWorkbook.Sheets(“策略组件”).Cells(i,12).Value
“风险终止日期”
ThisWorkbook.Sheets(“策略查看器”).Cells(a,11).Value=ThisWorkbook.Sheets(“策略组件”).Cells(i,13).Value
“是的。支付总额
ThisWorkbook.Sheets(“策略查看器”)。行(a+1&“:”&a+1)。插入
'插入空行
a=a+1
如果结束
接下来我
'计划/组件表结束
"有关政策详情,
DetailsCenter=ThisWorkbook.Sheets(“PolicyDetails”).UsedRange.Rows.Count
对于b=4,详细信息输入步骤1
如果此工作簿.Sheets(“PolicyDetails”).Cells(b,3).Value=box,则
'策略查看器
ThisWorkbook.Sheets(“策略查看器”).Cells(2,3).Value=ThisWorkbook.Sheets(“策略详细信息”).Cells(b,1).Value
'策略所有者名称
ThisWorkbook.Sheets(“策略查看器”).Cells(3,3).Value=ThisWorkbook.Sheets(“策略详细信息”).Cells(b,2).Value
“计划类型
ThisWorkbook.Sheets(“策略查看器”).Cells(4,3).Value=ThisWorkbook.Sheets(“策略详细信息”).Cells(b,3).Value
'策略编号***
ThisWorkbook.Sheets(“策略查看器”).Cells(5,3).Value=ThisWorkbook.Sheets(“策略详细信息”).Cells(b,4).Value
"政策地位"
ThisWorkbook.Sheets(“策略查看器”).Cells(6,3).Value=ThisWorkbook.Sheets(“策略详细信息”).Cells(b,5).Value
“付款方式
ThisWorkbook.Sheets(“策略查看器”).Cells(7,3).Value=ThisWorkbook.Sheets(“策略详细信息”).Cells(b,6).Value
“迄今为止已支付
ThisWorkbook.Sheets(“策略查看器”).Cells(8,3).Value=ThisWorkbook.Sheets(“策略详细信息”).Cells(b,7).Value
“频率
ThisWorkbook.Sheets(“策略查看器”).Cells(9,3).Value=ThisWorkbook.Sheets(“策略详细信息”).Cells(b,8).Value
“保险费$
ThisWorkbook.Sheets(“策略查看器”).Cells(10,3).Value=ThisWorkbook.Sheets(“策略详细信息”).Cells(b,9).Value
“悬而未决的金额
ThisWorkbook.Sheets(“策略查看器”).Cells(11,3).Value=ThisWorkbook.Sheets(“策略详细信息”).Cells(b,16).Value
“维修代理
ThisWorkbook.Sheets(“策略查看器”).Cells(7,9).Value=ThisWorkbook.Sheets(“策略详细信息”).Cells(b,10).Value
"生命有保障",
ThisWorkbook.Sheets(“策略查看器”).Cells(8,9)。Value=ThisWorkbook.Sheets(“策略详细信息”)
p = 21
'For Funds Invested table
Do While (ThisWorkbook.Sheets("Policy Viewer").Range("B" & p) <> "")
ThisWorkbook.Sheets("Policy Viewer").Rows(p & ":" & p).Delete
Loop
ThisWorkbook.Sheets("Policy Viewer").Cells(d, 6).Value = ThisWorkbook.Sheets("Fund Information").Cells(c, 8).Value
'Unit Value as at
ThisWorkbook.Sheets("Policy Viewer").Rows(d + 1 & ":" & d + 1).Insert
'insert blank lines
d = d + 1
End If
Next c
'End of Fund Invested Table
m = p + 3
e = 24 ' start of component
'For Components Table
Do While (ThisWorkbook.Sheets("Policy Viewer").Range("B" & m) <> "")
ThisWorkbook.Sheets("Policy Viewer").Rows(m & ":" & m).Delete
Loop