在过程级别设置variables以便在公共场合使用? “对象所需的错误”

MODULE01

Option Explicit Public target_des As Range, target_tot As Range Private Sub get_columns_letters() ' ' ' alot of lines which is irrelevant ' to set the target column as the total column If Not tot_tot_col_U Is Nothing Then target_tot = tot_tot_col_U ElseIf Not tot_totalcell Is Nothing Then target_tot = tot_totalcell Else target_tot = ActiveSheet.Range("U") End If ' to set the target column as description col If Not description_col_U Is Nothing Then target_des = description_col_U ElseIf Not Descell Is Nothing Then target_des = Descell Else target_des = ActiveSheet.Range("B") End If End Sub 

MODULE02

 Private Sub Organize_other() Application.Calculation = xlCalculationManual Application.ScreenUpdating = False Sheets("Project cost proposal").Activate Dim fstcell As Range Dim lstcell As Range Set fstcell = Cells(1, 1) Set lstcell = Cells(ActiveSheet.Rows.Count, ActiveSheet.Columns.Count) Range(fstcell, lstcell).Select Application.CutCopyMode = False Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False Dim Firstrow As Long Dim lastrow As Long Dim Lrow As Long Dim CalcMode As Long Dim ViewMode As Long With Sheets("Project cost proposal") .Select ViewMode = ActiveWindow.View ActiveWindow.View = xlNormalView .DisplayPageBreaks = False Firstrow = .UsedRange.Cells(1).Row lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row For Lrow = lastrow To Firstrow Step -1 Select Case Lrow Case 1, 2, 3 Case Else With .Cells(Lrow, target_tot.Column) ' HERE IS MY PROBLEM If Not IsError(.Value) Then If .Value = "0" Or .Value = "" Then .EntireRow.Delete End If End With End Select Next Lrow End With ActiveWindow.View = ViewMode ' RUN OTHER MACROS TO COMPLETE ORGANIZING SHEET Range("A1").Select Application.Run "module07.AssignUnique" Application.Run "module11.assign_formula_to_projectoverall" ' then adjust column and rows Worksheets("project cost proposal").Activate With Application ' to adjust cell size and auto fit Cells.Select Selection.Rows.AutoFit Selection.UnMerge Range(Cells(1, 1), Cells(ActiveSheet.Rows.Count, ActiveSheet.Columns.Count)).Select Selection.WrapText = False Selection.Rows.AutoFit End With End Sub 

所有用于标识target_tot的variables都是在模块1中定义的,所以当我在模块1中使用debugging时,它显示了target_tot的正确地址,但是在第二个模块中似乎已经回到没有任何东西或者不再被识别了。 一些用于制作程序的公开声明发现哪一列以“target_tot”为目标:

 Public description_col As String, unitcost_col As String, total_idiqpricing_col As String, mat_unit_cost_col As String Public mat_qty_col As String Public man_hours_col As String, rate_per_hour_col As String, eq_hours_col As String, eq_rate_per_hour_col As String Public sub_cost_col As String, L_tot_col As String, eq_tot_col As String, mat_tot_col As String, tot_tot_col As String Public description_col_U As Range ' for description column user selected Public tot_tot_col_U As Range Public Descell As Variant, tot_totalcell As Variant 

它总是给我在第二个模块所需的错误对象target_tot是没有任何可以帮助吗?