473,388 Members | 1,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

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.

Expand|Select|Wrap|Line Numbers
  1. Sub Update1()
  2. '
  3. ' Macro4 Macro
  4. '  
  5.     Dim SaveString As String
  6.     Dim sstr As String
  7.     Dim pptr As String
  8.     For X = 1 To 10
  9.         pptr = ActiveSheet.Range("be2").Value
  10.         Workbooks.Open Filename:="2006 02 " & pptr & " 0000 (Wide).dbf"
  11.         Range("A2:ay1443").Select
  12.         Selection.Copy
  13.         Windows("Template1.xlsx").Activate
  14.         Range("A3").Select
  15.         ActiveSheet.Paste
  16.         Columns("BB:BB").Select
  17.         Application.CutCopyMode = False
  18.         Selection.Copy
  19.         Columns("D:D").Select
  20.         ActiveSheet.Paste
  21.         Range("BC2").Select
  22.         Application.CutCopyMode = False
  23.         Selection.Copy
  24.         Range("A1").Select
  25.         Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
  26.             :=False, Transpose:=False
  27.         Application.CutCopyMode = False
  28.         Range("BE3").Select
  29.         Selection.Copy
  30.         Range("BE2").Select
  31.         Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
  32.             :=False, Transpose:=False
  33.         ActiveWorkbook.Save
  34.         sstr = ActiveSheet.Range("A1").Value
  35.         SaveString = sstr & ".xlsx"
  36.         ActiveWorkbook.SaveAs Filename:=SaveString _
  37.             , FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
  38.         ActiveWorkbook.Close
  39.         ActiveWorkbook.Close
  40.         Workbooks.Open Filename:="Template1.xlsx"
  41.     Next X
  42. End Sub
Mar 12 '08 #1
0 965

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: geronimo_me | last post by:
Hi, I have the following code in an access module: Sub Run_Excel_Macro() Dim xls, xlWB As Object Dim strFile, strMacro As String
6
by: geronimo_me | last post by:
Hi, I am trying to run an Excel macro from an Access module, however when I run the code the macro runs but then I get an error in Access. The error is: Run-time error "440", Automation error. ...
3
by: bwhite | last post by:
I have a temp table with one row of data that I need to export into Excel. I created the export to create the xls file as follows ... Dim FileName FileName = !! DoCmd.SetWarnings False...
14
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the...
0
by: Rich Wallace | last post by:
Hello all, Looking for suggestions and tips if possible. I have an application running on a file server that utilizes the FileSystemWatcher to trap when any Excel files are saved by a user. I...
3
by: Mr.Doubt | last post by:
I'm trying to run a Excel macro, which uses SOLVER.XLA Add-In, in VB.NET application. When the macro is executed I get the following error message "Solver: An unexpected internal error occured,...
10
by: Steve | last post by:
I am trying to create a DLL in Visual Studio 2005-Visual Basic that contains custom functions. I believe I need to use COM interop to allow VBA code in Excel 2002 to access it. I've studied...
2
by: Senthil | last post by:
Hi All I need to create an Excel report and create a command button and have to run a macro on the click event that will print all the pages in the Excel workbook. I am able to create the report...
7
by: Holger Fitschen | last post by:
Hi to all, I want to use the Excel solver in a VB.Net project. The macro Sub Makro1Solver() Application.Run "Solver.xla!Auto_Open" SolverReset Worksheets(1).Select...
1
by: Catbkr1 | last post by:
I have to automatically create some Excel Spreadsheets based on automatically generated .CSV files that are produced overnight. Each .CSV has several columns that need to be deleted. The same...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.