我需要帮助逐行计算某个单词并填充每列下的出现总数。现在,我的代码正在计算某个单词的总数,直到 GM 列以及该列之后的任何内容,我得到 #N/A。我不知道这是否应该发生。这是我到目前为止的代码。
Option Compare Text
Sub Count_Named_Entities()
Dim Sum_of_ABS01 As Long
Dim Sum_of_ABS02 As Long
Dim Sum_of_Academ As Long
Dim Sum_of_Active As Long
Dim Sum_of_AffGain As Long
Dim Sum_of_Affil As Long
Dim Sum_of_AffLoss As Long
Dim Sum_of_AffOth As Long
Dim Sum_of_AffPt As Long
Dim Sum_of_AffTot As Long
Dim Sum_of_ANI As Long
Dim Sum_of_Anomie As Long
Dim Sum_of_Aquatic As Long
Dim Sum_of_ArenaLw As Long
Dim Sum_of_Arousal As Long
Dim Sum_of_Begin As Long
Dim Sum_of_BldgPt As Long
Dim Sum_of_BodyPt As Long
Dim Sum_of_CARD As Long
Dim Sum_of_Causal As Long
Dim Sum_of_COLL As Long
Dim Sum_of_COLOR As Long
Dim Sum_of_COM As Long
Dim Sum_of_ConForm As Long
Dim Sum_of_ComnObj As Long
Dim Sum_of_Compare As Long
Dim Sum_of_Complet As Long
Dim Sum_of_DAV As Long
Dim Sum_of_Decreas As Long
Dim Sum_of_DIM As Long
Dim Sum_of_DIST As Long
Dim Sum_of_Doctrin As Long
Dim Sum_of_Econ01 As Long
Dim Sum_of_Econ02 As Long
Dim Sum_of_EMOT As Long
Dim Sum_of_EndsLw As Long
Dim Sum_of_EnlEnds As Long
Dim Sum_of_EnlGain As Long
Dim Sum_of_EnlLoss As Long
Dim Sum_of_EnlOth As Long
Dim Sum_of_EnlPt As Long
Dim Sum_of_EnlTot As Long
Dim Sum_of_EVAL01 As Long
Dim Sum_of_Eval02 As Long
Dim Sum_of_Exch As Long
Dim Sum_of_Exert As Long
Dim Sum_of_Exprsv As Long
Dim Sum_of_Fail As Long
Dim Sum_of_Fall As Long
Dim Sum_of_Feel As Long
Dim Sum_of_Female As Long
Dim Sum_of_Fetch As Long
Dim Sum_of_Finish As Long
Dim Sum_of_Food As Long
Dim Sum_of_FormLw As Long
Dim Sum_of_FREQ As Long
Dim Sum_of_Goal As Long
Dim Sum_of_Hostile As Long
Dim Sum_of_HU As Long
Dim Sum_of_IAV As Long
Dim Sum_of_If As Long
Dim Sum_of_Increas As Long
Dim Sum_of_IndAdj As Long
Dim Sum_of_Intrj As Long
Dim Sum_of_IPadj As Long
Dim Sum_of_Is_In_General_Inquirer As Long
Dim Sum_of_Kin As Long
Dim Sum_of_Know As Long
Dim Sum_of_Land As Long
Dim Sum_of_Legal As Long
Dim Sum_of_MALE As Long
Dim Sum_of_Means As Long
Dim Sum_of_MeansLw As Long
Dim Sum_of_Milit As Long
Dim Sum_of_Name As Long
Dim Sum_of_Nation As Long
Dim Sum_of_NatObj As Long
Dim Sum_of_NatrPro As Long
Dim Sum_of_Need As Long
Dim Sum_of_NegAff As Long
Dim Sum_of_Negate As Long
Dim Sum_of_Negativ As Long
Dim Sum_of_Ngtv As Long
Dim Sum_of_No As Long
Dim Sum_of_Nonadlt As Long
Dim Sum_of_NotLw As Long
Dim Sum_of_NUMB As Long
Dim Sum_of_Object As Long
Dim Sum_of_ORD As Long
Dim Sum_of_Ought As Long
Dim Sum_of_Our As Long
Dim Sum_of_Ovrst As Long
Dim Sum_of_Pain As Long
Dim Sum_of_Passive As Long
Dim Sum_of_Perceiv As Long
Dim Sum_of_Persist As Long
Dim Sum_of_PLACE As Long
Dim Sum_of_Pleasur As Long
Dim Sum_of_Polit01 As Long
Dim Sum_of_Polit02 As Long
Dim Sum_of_POS As Long
Dim Sum_of_PosAff As Long
Dim Sum_of_Positiv As Long
Dim Sum_of_PowAren As Long
Dim Sum_of_PowAuPt As Long
Dim Sum_of_PowAuth As Long
Dim Sum_of_PowCon As Long
Dim Sum_of_PowCoop As Long
Dim Sum_of_PowDoct As Long
Dim Sum_of_PowEnds As Long
Dim Sum_of_Power As Long
Dim Sum_of_PowGain As Long
Dim Sum_of_PowLoss As Long
Dim Sum_of_PowOth As Long
Dim Sum_of_PowPtas As Long
Dim Sum_of_PowTot As Long
Dim Sum_of_Pstv As Long
Dim Sum_of_PtLw As Long
Dim Sum_of_Quality As Long
Dim Sum_of_Quan As Long
Dim Sum_of_Race As Long
Dim Sum_of_RcEnds As Long
Dim Sum_of_RcEthic As Long
Dim Sum_of_RcGain As Long
Dim Sum_of_RcLoss As Long
Dim Sum_of_RcRelig As Long
Dim Sum_of_RcTot As Long
Dim Sum_of_Region As Long
Dim Sum_of_Rel As Long
Dim Sum_of_Relig As Long
Dim Sum_of_Rise As Long
Dim Sum_of_Ritual As Long
Dim Sum_of_Role As Long
Dim Sum_of_Route As Long
Dim Sum_of_RspGain As Long
Dim Sum_of_RspLoss As Long
Dim Sum_of_RspOth As Long
Dim Sum_of_RspTot As Long
Dim Sum_of_Say As Long
Dim Sum_of_Self As Long
Dim Sum_of_SklAsth As Long
Dim Sum_of_SklOth As Long
Dim Sum_of_SklPt As Long
Dim Sum_of_SklTot As Long
Dim Sum_of_Sky As Long
Dim Sum_of_Social As Long
Dim Sum_of_SocRel As Long
Dim Sum_of_Solve As Long
Dim Sum_of_Space As Long
Dim Sum_of_Stay As Long
Dim Sum_of_Strong As Long
Dim Sum_of_Submit As Long
Dim Sum_of_SureLw As Long
Dim Sum_of_SV As Long
Dim Sum_of_Think As Long
Dim Sum_of_TIME01 As Long
Dim Sum_of_Time02 As Long
Dim Sum_of_TimeSpc As Long
Dim Sum_of_Tool As Long
Dim Sum_of_TranLw As Long
Dim Sum_of_Travel As Long
Dim Sum_of_TrnGain As Long
Dim Sum_of_TrnLoss As Long
Dim Sum_of_Try As Long
Dim Sum_of_Undrst As Long
Dim Sum_of_Vary As Long
Dim Sum_of_Vehicle As Long
Dim Sum_of_Vice As Long
Dim Sum_of_Virtue As Long
Dim Sum_of_Weak As Long
Dim Sum_of_WlbGain As Long
Dim Sum_of_WlbLoss As Long
Dim Sum_of_WlbPhys As Long
Dim Sum_of_WlbPsyc As Long
Dim Sum_of_WlbPt As Long
Dim Sum_of_WlbTot As Long
Dim Sum_of_WltOth As Long
Dim Sum_of_WltPt As Long
Dim Sum_of_WltTot As Long
Dim Sum_of_WltTran As Long
Dim Sum_of_Work As Long
Dim Sum_of_Yes As Long
Dim Sum_of_You As Long
Dim Sum_of_Bear As Long
Dim Sum_of_Ice As Long
Dim ActiveDocument As Object
Dim row As Integer
Dim txt As String
row = 3
Set ActiveDocument = CreateObject("Word.Document")
Do While Worksheets("Sample_Output_2").Cells(row, 1) <> ""
txt = Worksheets("Sample_Output_2").Cells(row, 2).Value
ActiveDocument.Content = txt
Sum_of_ABS01 = CountChar(txt, "ABS")
Sum_of_ABS02 = CountChar(txt, "ABS@")
Sum_of_Academ = CountChar(txt, "Academ")
Sum_of_Active = CountChar(txt, "Active")
Sum_of_AffPt = CountChar(txt, "AffPt")
Sum_of_AffTot = CountChar(txt, "AffTot")
Sum_of_ANI = CountChar(txt, "ANI")
Sum_of_Anomie = CountChar(txt, "Anomie")
Sum_of_Aquatic = CountChar(txt, "Aquatic")
Sum_of_ArenaLw = CountChar(txt, "ArenaLw")
Sum_of_Arousal = CountChar(txt, "Arousal")
Sum_of_Begin = CountChar(txt, "BeginS")
Sum_of_BldgPt = CountChar(txt, "BldgP")
Sum_of_BodyPt = CountChar(txt, "BodyPt")
Sum_of_CARD = CountChar(txt, "CARD")
Sum_of_Causal = CountChar(txt, "Causal")
Sum_of_COLL = CountChar(txt, "COLL")
Sum_of_COLOR = CountChar(txt, "COLOR")
Sum_of_COM = CountChar(txt, "COM")
Sum_of_ConForm = CountChar(txt, "ConForm")
Sum_of_ComnObj = CountChar(txt, "ComnObj")
Sum_of_Compare = CountChar(txt, "Compare")
Sum_of_Complet = CountChar(txt, "DAV")
Sum_of_DAV = CountChar(txt, "Complet")
Sum_of_Decreas = CountChar(txt, "Decreas")
Sum_of_DIM = CountChar(txt, "DIM")
Sum_of_DIST = CountChar(txt, "DIST")
Sum_of_Doctrin = CountChar(txt, "Doctrin")
Sum_of_Econ01 = CountChar(txt, "Econ")
Sum_of_Econ02 = CountChar(txt, "Econ@")
Sum_of_EMOT = CountChar(txt, "EMOT")
Sum_of_EndsLw = CountChar(txt, "EndsLw")
Sum_of_EnlEnds = CountChar(txt, "EnlEnds")
Sum_of_EnlGain = CountChar(txt, "EnlGain")
Sum_of_EnlLoss = CountChar(txt, "EnlLoss")
Sum_of_EnlOth = CountChar(txt, "EnlOth")
Sum_of_EnlPt = CountChar(txt, "EnlPt")
Sum_of_EnlTot = CountChar(txt, "EnlTot")
Sum_of_EVAL01 = CountChar(txt, "EVAL")
Sum_of_Eval02 = CountChar(txt, "Eval@")
Sum_of_Exch = CountChar(txt, "Exch")
Sum_of_Exert = CountChar(txt, "Exert")
Sum_of_Exprsv = CountChar(txt, "Exprsv")
Sum_of_Fail = CountChar(txt, "Failt")
Sum_of_Fall = CountChar(txt, "Fall")
Sum_of_Feel = CountChar(txt, "Feel")
Sum_of_Female = CountChar(txt, "Female")
Sum_of_Fetch = CountChar(txt, "Fetch")
Sum_of_Finish = CountChar(txt, "Finish")
Sum_of_Food = CountChar(txt, "Food")
Sum_of_FormLw = CountChar(txt, "FormLw")
Sum_of_FREQ = CountChar(txt, "FREQ")
Sum_of_Goal = CountChar(txt, "Goal")
Sum_of_Hostile = CountChar(txt, "Hostile")
Sum_of_HU = CountChar(txt, "HU")
Sum_of_IAV = CountChar(txt, "IAV")
Sum_of_If = CountChar(txt, "If")
Sum_of_Increas = CountChar(txt, "Increas")
Sum_of_IndAdj = CountChar(txt, "IndAdj")
Sum_of_Intrj = CountChar(txt, "Intrj")
Sum_of_IPadj = CountChar(txt, "IPadj")
Sum_of_Is_In_General_Inquirer = CountChar(txt, "Is In General Inquirer")
Sum_of_Kin = CountChar(txt, "Kin")
Sum_of_Know = CountChar(txt, "Know")
Sum_of_Land = CountChar(txt, "Land")
Sum_of_Legal = CountChar(txt, "Legal")
Sum_of_MALE = CountChar(txt, "MALE")
Sum_of_Means = CountChar(txt, "Means")
Sum_of_MeansLw = CountChar(txt, "MeansLw")
Sum_of_Milit = CountChar(txt, "Milit")
Sum_of_Name = CountChar(txt, "Name")
Sum_of_NatObj = CountChar(txt, "NatObj")
Sum_of_NatrPro = CountChar(txt, "NatrPro")
Sum_of_Need = CountChar(txt, "Need")
Sum_of_NegAff = CountChar(txt, "NegAff")
Sum_of_Negate = CountChar(txt, "Negate")
Sum_of_Negativ = CountChar(txt, "Negativ")
Sum_of_Ngtv = CountChar(txt, "Ngtv")
Sum_of_No = CountChar(txt, "No")
Sum_of_Nonadlt = CountChar(txt, "Nonadlt")
Sum_of_NotLw = CountChar(txt, "NotLw")
Sum_of_NUMB = CountChar(txt, "NUMB")
Sum_of_Object = CountChar(txt, "Object")
Sum_of_ORD = CountChar(txt, "ORD")
Sum_of_Ought = CountChar(txt, "Ought")
Sum_of_Our = CountChar(txt, "Our")
Sum_of_Ovrst = CountChar(txt, "Ovrst")
Sum_of_Pain = CountChar(txt, "Pain")
Sum_of_Passive = CountChar(txt, "Passive")
Sum_of_Perceiv = CountChar(txt, "Perceiv")
Sum_of_Persist = CountChar(txt, "Persist")
Sum_of_PLACE = CountChar(txt, "PLACE")
Sum_of_Pleasur = CountChar(txt, "Pleasur")
Sum_of_Polit01 = CountChar(txt, "Polit")
Sum_of_Polit02 = CountChar(txt, "Polit@")
Sum_of_POS = CountChar(txt, "POS")
Sum_of_PosAff = CountChar(txt, "PosAff")
Sum_of_Positiv = CountChar(txt, "Positiv")
Sum_of_PowAren = CountChar(txt, "PowAren")
Sum_of_PowAuPt = CountChar(txt, "PowAuPt")
Sum_of_PowAuth = CountChar(txt, "PowAuth")
Sum_of_PowCon = CountChar(txt, "PowCon")
Sum_of_PowCoop = CountChar(txt, "PowCoop")
Sum_of_PowDoct = CountChar(txt, "PowDoct")
Sum_of_PowEnds = CountChar(txt, "PowEnds")
Sum_of_Power = CountChar(txt, "Power")
Sum_of_PowGain = CountChar(txt, "PowGain")
Sum_of_PowLoss = CountChar(txt, "PowLoss")
Sum_of_PowOth = CountChar(txt, "PowOth")
Sum_of_PowPtas = CountChar(txt, "PowPtas")
Sum_of_PowTot = CountChar(txt, "PowTot")
Sum_of_Pstv = CountChar(txt, "Pstv")
Sum_of_PtLw = CountChar(txt, "PtLw")
Sum_of_Quality = CountChar(txt, "Quality")
Sum_of_Quan = CountChar(txt, "Quan")
Sum_of_Race = CountChar(txt, "Race")
Sum_of_RcEnds = CountChar(txt, "RcEnds")
Sum_of_RcEthic = CountChar(txt, "RcEthic")
Sum_of_RcGain = CountChar(txt, "RcGain")
Sum_of_RcLoss = CountChar(txt, "RcLoss")
Sum_of_RcRelig = CountChar(txt, "RcRelig")
Sum_of_RcTot = CountChar(txt, "RcTot")
Sum_of_Region = CountChar(txt, "Region")
Sum_of_Rel = CountChar(txt, "Rel")
Sum_of_Relig = CountChar(txt, "Relig")
Sum_of_Rise = CountChar(txt, "Rise")
Sum_of_Ritual = CountChar(txt, "Ritual")
Sum_of_Role = CountChar(txt, "Role")
Sum_of_Route = CountChar(txt, "Route")
Sum_of_RspGain = CountChar(txt, "RspGain")
Sum_of_RspLoss = CountChar(txt, "RspLoss")
Sum_of_RspOth = CountChar(txt, "RspOth")
Sum_of_RspTot = CountChar(txt, "RspTot")
Sum_of_Say = CountChar(txt, "Say")
Sum_of_Self = CountChar(txt, "Self")
Sum_of_SklAsth = CountChar(txt, "SklAsth")
Sum_of_SklOth = CountChar(txt, "SklOth")
Sum_of_SklPt = CountChar(txt, "SklPt")
Sum_of_SklTot = CountChar(txt, "SklTot")
Sum_of_Sky = CountChar(txt, "Sky")
Sum_of_Social = CountChar(txt, "Social")
Sum_of_SocRel = CountChar(txt, "SocRel")
Sum_of_Solve = CountChar(txt, "Solve")
Sum_of_Space = CountChar(txt, "Space")
Sum_of_Stay = CountChar(txt, "Stay")
Sum_of_Strong = CountChar(txt, "Strong")
Sum_of_Submit = CountChar(txt, "Submit")
Sum_of_SureLw = CountChar(txt, "SureLw")
Sum_of_SV = CountChar(txt, "SV")
Sum_of_Think = CountChar(txt, "Think")
Sum_of_TIME01 = CountChar(txt, "TIME")
Sum_of_Time02 = CountChar(txt, "Time@")
Sum_of_TimeSpc = CountChar(txt, "TimeSpc")
Sum_of_Tool = CountChar(txt, "Tool")
Sum_of_TranLw = CountChar(txt, "TranLw")
Sum_of_Travel = CountChar(txt, "Travel")
Sum_of_TrnGain = CountChar(txt, "TrnGain")
Sum_of_TrnLoss = CountChar(txt, "TrnLoss")
Sum_of_Try = CountChar(txt, "Try")
Sum_of_Undrst = CountChar(txt, "Undrst")
Sum_of_Vary = CountChar(txt, "Vary")
Sum_of_Vehicle = CountChar(txt, "Vehicle")
Sum_of_Vice = CountChar(txt, "Vice")
Sum_of_Virtue = CountChar(txt, "Virtue")
Sum_of_Weak = CountChar(txt, "Weak")
Sum_of_WlbGain = CountChar(txt, "WlbGain")
Sum_of_WlbLoss = CountChar(txt, "WlbLoss")
Sum_of_WlbPhys = CountChar(txt, "WlbPhys")
Sum_of_WlbPsyc = CountChar(txt, "WlbPsyc")
Sum_of_WlbPt = CountChar(txt, "WlbPt")
Sum_of_WlbTot = CountChar(txt, "WlbTot")
Sum_of_WltOth = CountChar(txt, "WltOth")
Sum_of_WltPt = CountChar(txt, "WltPt")
Sum_of_WltTot = CountChar(txt, "WltTot")
Sum_of_WltTran = CountChar(txt, "WltTran")
Sum_of_Work = CountChar(txt, "Work")
Sum_of_Yes = CountChar(txt, "Yes")
Sum_of_You = CountChar(txt, "You")
Sum_of_Bear = CountChar(txt, "Bear")
Sum_of_Ice = CountChar(txt, "ice")
Worksheets("Sample_Output_2").Cells(row, 16).Resize(1, 185).Value = _
Array(Sum_of_ABS01, Sum_of_ABS02, Sum_of_Academ, Sum_of_Active, Sum_of_AffPt, Sum_of_AffTot, Sum_of_ANI, Sum_of_Anomie, _
Sum_of_Aquatic, Sum_of_ArenaLw, Sum_of_Arousal, Sum_of_Begin, Sum_of_BldgPt, Sum_of_BodyPt, Sum_of_CARD, Sum_of_Causal, _
Sum_of_COLL, Sum_of_COLOR, Sum_of_COM, Sum_of_ConForm, Sum_of_ComnObj, Sum_of_Compare, Sum_of_Complet, Sum_of_DAV, _
Sum_of_Decreas, Sum_of_DIM, Sum_of_DIST, Sum_of_Doctrin, Sum_of_Econ01, Sum_of_Econ02, Sum_of_EMOT, Sum_of_EndsLw, _
Sum_of_EnlEnds, Sum_of_EnlGain, Sum_of_EnlLoss, Sum_of_EnlOth, Sum_of_EnlPt, Sum_of_EnlTot, Sum_of_EVAL01, Sum_of_Eval02, _
Sum_of_Exch, Sum_of_Exert, Sum_of_Exprsv, Sum_of_Fail, Sum_of_Fall, Sum_of_Feel, Sum_of_Female, Sum_of_Fetch, Sum_of_Finish, _
Sum_of_Food, Sum_of_FormLw, Sum_of_FREQ, Sum_of_Goal, Sum_of_Hostile, Sum_of_HU, Sum_of_IAV, Sum_of_If, Sum_of_Increas, _
Sum_of_IndAdj, Sum_of_Intrj, Sum_of_IPadj, Sum_of_Is_In_General_Inquirer, Sum_of_Kin, Sum_of_Know, Sum_of_Land, _
Sum_of_Legal, Sum_of_MALE, Sum_of_Means, Sum_of_MeansLw, Sum_of_Milit, Sum_of_Name, Sum_of_NatObj, Sum_of_NatrPro, _
Sum_of_Need, Sum_of_NegAff, Sum_of_Negate, Sum_of_Negativ, Sum_of_Ngtv, Sum_of_No, Sum_of_Nonadlt, Sum_of_NotLw, Sum_of_NUMB, _
Sum_of_Object, Sum_of_ORD, Sum_of_Ought, Sum_of_Our, Sum_of_Ovrst, Sum_of_Pain, Sum_of_Passive, Sum_of_Perceiv, _
Sum_of_Persist, Sum_of_PLACE, Sum_of_Pleasur, Sum_of_Polit01, Sum_of_Polit02, Sum_of_POS, Sum_of_PosAff, Sum_of_Positiv, _
Sum_of_PowAren, Sum_of_PowAuPt, Sum_of_PowAuth, Sum_of_PowCon, Sum_of_PowCoop, Sum_of_PowDoct, Sum_of_PowEnds, Sum_of_Power, _
Sum_of_PowGain, Sum_of_PowLoss, Sum_of_PowOth, Sum_of_PowPtas, Sum_of_PowTot, Sum_of_Pstv, Sum_of_PtLw, Sum_of_Quality, _
Sum_of_Quan, Sum_of_Race, Sum_of_RcEnds, Sum_of_RcEthic, Sum_of_RcGain, Sum_of_RcLoss, Sum_of_RcRelig, Sum_of_RcTot, _
Sum_of_Region, Sum_of_Rel, Sum_of_Relig, Sum_of_Rise, Sum_of_Ritual, Sum_of_Role, Sum_of_Route, Sum_of_RspGain, _
Sum_of_RspLoss, Sum_of_RspOth, Sum_of_RspTot, Sum_of_Say, Sum_of_Self, Sum_of_SklAsth, Sum_of_SklOth, Sum_of_SklPt, _
Sum_of_SklTot, Sum_of_Sky, Sum_of_Social, Sum_of_SocRel, Sum_of_Solve, Sum_of_Space, Sum_of_Stay, Sum_of_Strong, _
Sum_of_Submit, Sum_of_SureLw, Sum_of_SV, Sum_of_Think, Sum_of_TIME01, Sum_of_Time02, Sum_of_TimeSpc, Sum_of_Tool, Sum_of_TranLw, _
Sum_of_Travel, Sum_of_TrnGain, Sum_of_TrnLoss, Sum_of_Try, Sum_of_Undrst, Sum_of_Vary, Sum_of_Vehicle, Sum_of_Vice, _
Sum_of_Virtue, Sum_of_Weak, Sum_of_WlbGain, Sum_of_WlbLoss, Sum_of_WlbPhys, Sum_of_WlbPsyc, Sum_of_WlbPt, Sum_of_WlbTot, _
Sum_of_WltOth, Sum_of_WltPt, Sum_of_WltTot, Sum_of_WltTran, Sum_of_Work, Sum_of_Yes, Sum_of_You, Sum_of_Bear, Sum_of_Ice)
row = row + 1
Loop
End Sub
Function CountChar(txt As String, char As String) As Long
CountChar = Len(txt) - Len(Replace(txt, char, ""))
End Function