B
Bob
I have written two routines, each for a different sheet. Both work as
individual routines, however, when I cal the one routine from the other
routine, I get error message 1004
Application-defined Object-defined Error.
I think the problem has to do with cells or ranges being selected on
each sheet and I have having problems getting the program to recognize
the activesheet.
Can someone Help ??
See routine(s) Range1Update and ExtractSumCode
***********************************************************************************************************
Sub ExtractSumCode()
'Purpose: ExtractCustCode() procedure extracts the related Customer
code from
'the Reference worksheet tables
Dim i As Integer
Dim RCount As Long
Dim SumCode As Range, TestTable As Range
Dim cell As Range
Call Worksheets("Reference").Range1Update
With Worksheets("AR_Aging").Range("A2")
RCount = Range(.Offset(0, 0), .End(xlDown)).Count
ActiveSheet.Range("A1").Select
End With
With Worksheets("AR_Aging").Range("M2")
.Formula = "=VlookUp(A2,Range1,3)"
End With
With Worksheets("AR_Aging").Range("M2")
.Copy
Range(.Offset(1, 0), .Offset(RCount - 1, 0)).Select
ActiveSheet.Paste
Application.CutCopyMode = False
End With
With Worksheets("AR_Aging").Range("M1")
.Value = "SumCode"
.Font.Bold = True
Range("P1").Range(.Offset(1, 0), .End(xlDown)).Name = "SumCode"
End With
End Sub
***************************************************************************************************
Sub Range1Update()
'This routine updates the range "Range1" to provide an effective table
for customer SumCode
ActiveWorkbook.Names("Range1").Delete
With Worksheets("Reference").Range("D1")
Range(.Offset(0, 0), .Offset(0, 2).End(xlDown)).Name = "Range1"
ActiveSheet.Range("A1").Select
End With
With Worksheets("Reference").Range("D1")
ActiveSheet.Range(.End(xlToRight), .End(xlDown)).Select
Selection.Sort Key1:=Range("D1"), Order1:=xlAscending, _
Header:=xlNo, OrderCustom:=1, MatchCase:=False _
, Orientation:=xlTopToBottom, DataOption1:=xlSortTextAsNumbers,
_
DataOption2:=xlSortNormal
End With
With Worksheets("AR_Aging").Range("A65300")
End With
End Sub
individual routines, however, when I cal the one routine from the other
routine, I get error message 1004
Application-defined Object-defined Error.
I think the problem has to do with cells or ranges being selected on
each sheet and I have having problems getting the program to recognize
the activesheet.
Can someone Help ??
See routine(s) Range1Update and ExtractSumCode
***********************************************************************************************************
Sub ExtractSumCode()
'Purpose: ExtractCustCode() procedure extracts the related Customer
code from
'the Reference worksheet tables
Dim i As Integer
Dim RCount As Long
Dim SumCode As Range, TestTable As Range
Dim cell As Range
Call Worksheets("Reference").Range1Update
With Worksheets("AR_Aging").Range("A2")
RCount = Range(.Offset(0, 0), .End(xlDown)).Count
ActiveSheet.Range("A1").Select
End With
With Worksheets("AR_Aging").Range("M2")
.Formula = "=VlookUp(A2,Range1,3)"
End With
With Worksheets("AR_Aging").Range("M2")
.Copy
Range(.Offset(1, 0), .Offset(RCount - 1, 0)).Select
ActiveSheet.Paste
Application.CutCopyMode = False
End With
With Worksheets("AR_Aging").Range("M1")
.Value = "SumCode"
.Font.Bold = True
Range("P1").Range(.Offset(1, 0), .End(xlDown)).Name = "SumCode"
End With
End Sub
***************************************************************************************************
Sub Range1Update()
'This routine updates the range "Range1" to provide an effective table
for customer SumCode
ActiveWorkbook.Names("Range1").Delete
With Worksheets("Reference").Range("D1")
Range(.Offset(0, 0), .Offset(0, 2).End(xlDown)).Name = "Range1"
ActiveSheet.Range("A1").Select
End With
With Worksheets("Reference").Range("D1")
ActiveSheet.Range(.End(xlToRight), .End(xlDown)).Select
Selection.Sort Key1:=Range("D1"), Order1:=xlAscending, _
Header:=xlNo, OrderCustom:=1, MatchCase:=False _
, Orientation:=xlTopToBottom, DataOption1:=xlSortTextAsNumbers,
_
DataOption2:=xlSortNormal
End With
With Worksheets("AR_Aging").Range("A65300")
End With
End Sub