ActiveSheet.Paste crashes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following commands in a VB Project:

ActiveSheet.Paste

It does not run after the point where the above line is, even after the
macro has pasted the info I want. I was working on XL2000 but recently was
upgraded to XL2003. Macro worked fine before.

Thanks.
 
Look below between the * lines.

Thanks.


With ActiveSheet.QueryTables.Add(Connection:= _
"FINDER;C:\Documents and Settings\mrodas\Application
Data\Microsoft\Queries\Trace Table Query.dqy" _
, Destination:=Range("A1"))
.Name = "Trace Table Query"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With


Yearanalysis = InputBox("What year?", "Year")

CurrentPeriod = InputBox("What period (SINGLE DIGIT 1-9)?", "Current
Period")
If CurrentPeriod = "" Then



Range("A1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=8, Criteria1:=Yearanalysis
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Sheets("Sheet3").Select
ActiveSheet.Paste
Cells.Select
Cells.EntireColumn.AutoFit
Range("A1").Select
Sheets("Sheet1").Select
Application.CutCopyMode = False

Sheets("Sheet2").Select
Range("M1").Select
Selection.Sort Key1:=Range("M1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Selection.Subtotal GroupBy:=13, Function:=xlCount, TotalList:=Array(13), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
ActiveSheet.Outline.ShowLevels RowLevels:=2
Columns("K:K").ColumnWidth = 14.14
Columns("L:L").ColumnWidth = 17

Else


Range("A1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=8, Criteria1:=Yearanalysis
Selection.AutoFilter Field:=9, Criteria1:=CurrentPeriod
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Sheets("Sheet3").Select
'******************************************************
ActiveSheet.Paste
'******************************************************
Cells.EntireColumn.AutoFit
Range("A1").Select
Sheets("Sheet1").Select
Application.CutCopyMode = False

Sheets("Sheet2").Select
Range("M1").Select
Selection.Sort Key1:=Range("M1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Selection.Subtotal GroupBy:=13, Function:=xlCount, TotalList:=Array(13), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
ActiveSheet.Outline.ShowLevels RowLevels:=2
Columns("K:K").ColumnWidth = 14.14
Columns("L:L").ColumnWidth = 17
End If


End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top