---
title: "VBA规则开发示例"
author: "cczmf"
date: "2020-07-20T16:00:00Z"
tags: []
categories: ["行业应用"]
slug: "vba"
draft: false
lastmod: "2020-07-20T16:00:00Z"
id: 2515775
url: "https://cczmf.iteye.com/blog/2515775"
---

1.对象属性获取及判断
HS.Entity.IsBase("Groups",strEntity)= True
HS.Entity.IsDescendant("HKGroups",strEntity) = True
HS.Entity.IsChild("QYGL",strEntity) = False
HS.Entity.UD1(strEntity) = "MHK"
HS.Entity.UD2(strEntity) <> "FZSTZ"
HS.Account.IsConsolidated(strAccount)
HS.Account.PlugAcct(strAccount) = "BSElim"
Hs.Account.List("QY","")
Hs.Value.Member
HS.PARENT.Member
Not HS.Entity.Member = "E1000099"
not(Hs.Custom4.IsBase("QYElim65A",strCustom4))
HS.Node.Consol1("")
HS.Node.Consol2("")
HS.Node.PCon("")
Hs.Node.ISDESCENDANT(strEntity, strICP, "")= True

2.集合处理
AccountList = ListTogether(AccArray1,AccArray2)
vAcc1List=Array("222101","222102","222103","222104","222105","222106")
List1.Count
NewList.Contains(List1(i)) = False
NewList.Add(List1(i))
For Each vAcc in vAccList ...  Next
Set DataUnit = Hs.OpenDataUnit("Y#"&strYear&".P#"&strPeriod&".C4#NCPRC"&C123None)
DataUnit.GetNumItems
DataUnit.GetItem(i, strAccount, strICP, strCustom1, strCustom2, strCustom3, strCustom4, vData)
Not AcctDict.Exists(AccElement)
AcctDict.Add AccElement,0
Set AcctDict=Nothing

3.字符串/数值/时间处理
left(vAcc,4)="4103"
Lcase(etyType)="msmart"
abs()
UCase(Hs.Account.AccountType(AccElement))
Now()

4.单元格处理
Hs.Clear "A#"&vAcc&INone&C123None&".C4#"&vC4
Hs.Clear("A#All.C4#NCPRC")
HS.ReviewStatus("S#"&strScenario&"...)  "Not Started"/"First Pass"/"Review Level 1"
HS.NoRound
HS.Round (0.01)
HS.Con ("",1,"")
Hs.Exp("A#All.C4#NCPRC.S#PRC = A#All.S#PRCNCinterface")
Hs.Exp "A#224114.C4#RoomRe2"&C123None &"=A#122113.C4#RoomRe1"&C123None
Hs.GetCell("S#PRCEBSinterface.A#...)
Hs.GetCellRealData("E#" &entParent & ".I#" & strEntity & ".V#.A#"&allCNone,cons1Flag)
Hs.Input "A#area"

5.方法调用
Call Cal_CopyScenario()


6.多条件判断
Select Case left(StrAccount,6) Case "112201"  StrAcc="1" Case Else StrAcc="" End Select

7.对象创建及写文件
Set AcctDict = CreateObject("Scripting.Dictionary")
Set f = fso.OpenTextFile(logPath, ForAppending, True)
f.WriteLine Now()