Excel Macro run error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • semme001
    New Member
    • Mar 2008
    • 1

    Excel Macro run error

    I have a macro that ran normally for about 6 cycles but apparently developed an error? It appears to stall on the second loop when it attempts to open the named workbook. Any suggestions would be most helpful!!
    Here is the code I am working with.

    [CODE=vb]Sub Update1()
    '
    ' Macro4 Macro
    '
    Dim SaveString As String
    Dim sstr As String
    Dim pptr As String
    For X = 1 To 10
    pptr = ActiveSheet.Ran ge("be2").Valu e
    Workbooks.Open Filename:="2006 02 " & pptr & " 0000 (Wide).dbf"
    Range("A2:ay144 3").Select
    Selection.Copy
    Windows("Templa te1.xlsx").Acti vate
    Range("A3").Sel ect
    ActiveSheet.Pas te
    Columns("BB:BB" ).Select
    Application.Cut CopyMode = False
    Selection.Copy
    Columns("D:D"). Select
    ActiveSheet.Pas te
    Range("BC2").Se lect
    Application.Cut CopyMode = False
    Selection.Copy
    Range("A1").Sel ect
    Selection.Paste Special Paste:=xlPasteV alues, Operation:=xlNo ne, SkipBlanks _
    :=False, Transpose:=Fals e
    Application.Cut CopyMode = False
    Range("BE3").Se lect
    Selection.Copy
    Range("BE2").Se lect
    Selection.Paste Special Paste:=xlPasteV alues, Operation:=xlNo ne, SkipBlanks _
    :=False, Transpose:=Fals e
    ActiveWorkbook. Save
    sstr = ActiveSheet.Ran ge("A1").Value
    SaveString = sstr & ".xlsx"
    ActiveWorkbook. SaveAs Filename:=SaveS tring _
    , FileFormat:=xlO penXMLWorkbook, CreateBackup:=F alse
    ActiveWorkbook. Close
    ActiveWorkbook. Close
    Workbooks.Open Filename:="Temp late1.xlsx"
    Next X
    End Sub[/CODE]
    Last edited by Killer42; Mar 14 '08, 04:30 AM. Reason: Added CODE=vb tag
Working...