【发布时间】:2016-10-14 13:47:41
【问题描述】:
我正在尝试使用 VBA 运行公式。我的最终目标是让它基于选定的一批单元格一键运行多个公式。有关我正在使用这些公式做什么的一些背景信息。我正在使用公式根据预填充的字段自动生成工作范围。举个例子:
Circuit ID scope data1 data2 data3 data4
123 a b c d
234 f g h j
我想突出显示电路 ID,并在相对于所选电路 ID 的范围内填写公式。到目前为止,这就是我所拥有的...我使用了宏记录器,但它不想工作。
Sub Formulas()
'
' Formulas Macro
'
'
Range("E2").Select
ActiveCell.Formula = "="• Customer name: ""&RC[29]&"""&chr(10)&"• Customer Bus Org: ""&RC[30]&"""&chr(10)&"• Internal Circuit ID: ""&RC[2]&"""&chr(10)&"• Customer prem address: ""&RC[12]&"" ""&RC[13]&"" ""&RC[14]&"", ""&RC[15]&"", ""&RC[16]&"", ""&RC[17]&"""&chr(10)&"• Customer demarc: ""&RC[18]&"" ""&RC[20]&"", ""&RC[19]&"" ""&RC[21]&"""&chr(10)&"• MRR: ""&RC[68]&"""&chr(10)&"• Current Off Net MRC: $""&RC[10]&"""&chr(10)&"• "& _
" Percent: ""&RC[89]&"""&chr(10)&"• Bandwidth: ""&RC[6]&"" ( ""&RC[7]&""Mb )"&chr(10)&"• Customer term end date: ""&TEXT(RC[32],""mmm-dd-yyyy"")&"""&chr(10)&"• New Vendor: ""&RC[106]&"""&chr(10)&"• New MRC: $""&RC[102]&"""&chr(10)&"• New NRC: $""&RC[103]&"""&chr(10)&"• New Install Interval: ""&RC[105]&"""&chr(10)&"• New Term: ""&RC[104]&"""&chr(10)&""&chr(10)&"Planner Notes:"&chr(10)&"This project is replacing the existing ""&RC[6]&"" ( "& _
"""Mb ) based solution from ( ""&RC[5]&"" ) with a new ""&RC[99]&"" ( ""&RC[100]&""Mb ) based solution from ( ""&RC[106]&"" ). "&chr(10)&""&chr(10)&"RFA # ""&RC[107]&"" install notes:"&chr(10)&"Please install ( ""&RC[31]&"" ) Ethernet ""&RC[99]&"" ( ""&RC[100]&""Mb ) circuit with ( ""&RC[106]&"" ) from ( ""&RC[101]&"" ) to ( [Customer Prem] ""&RC[12]&"" ""&RC[13]&"" ""&RC[14]&"", ""&RC[15]&"", "& _
"&"", ""&RC[17]&"" ). This new circuit will be used to replace existing customer circuit ECCKT: ""&RC[1]&"", ""&RC[109]&"", ""&RC[110]&"", ICCKT: ""&RC[2]&"". The customer prem address is ( ""&RC[12]&"" ""&RC[13]&"" ""&RC[14]&"", ""&RC[15]&"", ""&RC[16]&"", ""&RC[17]&"" ) and customer demarc is ( ""&RC[18]&"" ""&RC[20]&"", ""&RC[19]&"" ""&RC[21]&"" )."&chr(10)&""&chr(10)&""&chr(10)&"""""& _
End Sub
这是我的实际公式,我注意到录音机改变了很多东西。
="
- 客户名称:“&AH2&”
- 客户总线组织:“&AI2&”
- 内部电路 ID:“&G2&”
- 客户预置地址:“&Q2&”“&R2&”“&S2&”,“&T2&”,“&U2&”,“&V2&”
- 客户界限:“&W2&”“&Y2&”,“&X2&”“&Z2&”
- MRR:“&BU2&”
- 当前离网 MRC:$"&O2&"
- 保证金百分比:“&CP2&”
- 带宽:“&K2&”(“&L2&”Mb)
- 客户期限结束日期:"&TEXT(AK2,"mmm-dd-yyyy")&"
- 新供应商:“&DG2&”
- 新 MRC:$"&DC2&"
- 新 NRC:$"&DD2&"
- 新安装间隔:“&DF2&”
- 新术语:“&DE2&”
规划师备注:
这个项目正在替换现有的基于“&K2&”(“&L2&”Mb) 来自 ( "&J2&" ) 的解决方案,基于新的 "&CZ2&" ( "&DA2&"Mb ) 来自 ( "&DG2&" ) 的解决方案。
RFA #“&DH2&”安装说明:
请安装("&AJ2&")以太网"&CZ2&"("&DA2&"Mb)电路 与 ( "&DG2&" ) 从 ( "&DB2&" ) 到 ( [Customer Prem] "&Q2&" "&R2&" “&S2&”、“&T2&”、“&U2&”、“&V2&”)。这个新电路将用于 替换现有客户电路ECCKT:“&F2&”、“&DJ2&”、“&DK2&”、 ICCKT:“&G2&”。客户prem地址是(“&Q2&”“&R2&”“&S2&”, "&T2&", "&U2&", "&V2&" ) 和客户界限是 ( "&W2&" "&Y2&", "&X2&" "&Z2&")。
"
【问题讨论】: