D
Dave Y
I have an Excel wookbook that has three tabs. Two of the
tabs are for doing manual input such as adding and
deleting rows, or adding/deleting data. The third tab
(called Print) is meant to be read only where no manual
input is to be done. I have a macro that is run from a
button on the Print tab that combines all the manual input
from the other two tabs and formats it all nicely on the
Print tab for the purpose of updating the data and
printing it out. This macro works great. The problem I
have is that the macro formuls are located on the Print
tab and occasionally people who work in this workbook
forget not to do anything on the Print tab and they
sometimes add or delete rows and throw off the formulas.
So I created another tab called lookups and cut & pasted
the macro formulas to that tab with the intent of hiding
the lookups worksheet and eliminate the user errors. My
problem is that after I moved the formulas from the Print
worksheet to the lookups worksheet I am receiving a Run-
time error '6': Overflow when I run the macro. I have
included the code from the VB editor and I put *** before
the line of code that is highlighted when I run the
Debugger. I know this is a long post and I appreciate the
patience in reading it. Any help in resolving this macro
issue will be greatly appreciated.
Thanks, Dave (code below)
Dim cellloc As Integer
Dim cellloc2 As Integer
Application.Goto Reference:="clear"
Selection.RemoveSubtotal
Range("clear").Select
Selection.ClearContents
Application.Goto Reference:="formats"
Selection.Copy
Range("clear").Select
Selection.PasteSpecial Paste:=xlPasteFormats,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("LTOB").Select
Range("A2:B2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Print").Select
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.End(xlDown).Select
cellloc = ActiveCell.Row
Range("A" & cellloc + 1).Select
Sheets("LtrOC").Select
Range("A1").Select
Range("A2:B2").Activate
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Print").Select
ActiveSheet.Paste
Application.Goto Reference:="lookups"
Selection.Copy
Range("A2").Select
Selection.End(xlDown).Select
*** cellloc2 = ActiveCell.Row
Range("C2:C" & cellloc2).Select
ActiveSheet.Paste
Range("C2").Select
Range("A1:R" & cellloc2).Sort Key1:=Range("A2"),
Order1:=xlAscending, Key2:=Range _
("B2"), Order2:=xlAscending, Header:=xlGuess,
OrderCustom:=1, MatchCase _
:=False, Orientation:=xlTopToBottom,
DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal
Selection.Subtotal GroupBy:=1, Function:=xlSum,
TotalList:=Array(7, 8, 9, 10 _
), Replace:=True, PageBreaks:=False,
SummaryBelowData:=True
End Sub
tabs are for doing manual input such as adding and
deleting rows, or adding/deleting data. The third tab
(called Print) is meant to be read only where no manual
input is to be done. I have a macro that is run from a
button on the Print tab that combines all the manual input
from the other two tabs and formats it all nicely on the
Print tab for the purpose of updating the data and
printing it out. This macro works great. The problem I
have is that the macro formuls are located on the Print
tab and occasionally people who work in this workbook
forget not to do anything on the Print tab and they
sometimes add or delete rows and throw off the formulas.
So I created another tab called lookups and cut & pasted
the macro formulas to that tab with the intent of hiding
the lookups worksheet and eliminate the user errors. My
problem is that after I moved the formulas from the Print
worksheet to the lookups worksheet I am receiving a Run-
time error '6': Overflow when I run the macro. I have
included the code from the VB editor and I put *** before
the line of code that is highlighted when I run the
Debugger. I know this is a long post and I appreciate the
patience in reading it. Any help in resolving this macro
issue will be greatly appreciated.
Thanks, Dave (code below)
Dim cellloc As Integer
Dim cellloc2 As Integer
Application.Goto Reference:="clear"
Selection.RemoveSubtotal
Range("clear").Select
Selection.ClearContents
Application.Goto Reference:="formats"
Selection.Copy
Range("clear").Select
Selection.PasteSpecial Paste:=xlPasteFormats,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("LTOB").Select
Range("A2:B2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Print").Select
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.End(xlDown).Select
cellloc = ActiveCell.Row
Range("A" & cellloc + 1).Select
Sheets("LtrOC").Select
Range("A1").Select
Range("A2:B2").Activate
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Print").Select
ActiveSheet.Paste
Application.Goto Reference:="lookups"
Selection.Copy
Range("A2").Select
Selection.End(xlDown).Select
*** cellloc2 = ActiveCell.Row
Range("C2:C" & cellloc2).Select
ActiveSheet.Paste
Range("C2").Select
Range("A1:R" & cellloc2).Sort Key1:=Range("A2"),
Order1:=xlAscending, Key2:=Range _
("B2"), Order2:=xlAscending, Header:=xlGuess,
OrderCustom:=1, MatchCase _
:=False, Orientation:=xlTopToBottom,
DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal
Selection.Subtotal GroupBy:=1, Function:=xlSum,
TotalList:=Array(7, 8, 9, 10 _
), Replace:=True, PageBreaks:=False,
SummaryBelowData:=True
End Sub