Problem with macro: 1004 error
Give this a try...
Sub Main()
Dim wksTo As Worksheet
Dim wksFrom As Worksheet
Set wksFrom = ActiveSheet
Set wksTo = Sheets.Add
wksFrom.Cells.Copy wksTo.Range("A1")
wksTo.Select
wksTo.Columns("A:H").Select ' this line is where it screws up
End Sub
It defines the sheets that we are working with explicitly, which may have
been your problem...
HTH
" wrote:
Ok... This should be simple enough. Basically the Macro grabs the
entire contents of a sheet, creates a new sheet in the workbook, and
then tries to manipulate that new sheet.
Problem is, 50% of the time, a 1004 Error occurs when it begins to
makes changes to the new sheet.
Here's the relevant code:
Sub Main
Cells.Select
Selection.Copy
Sheets.Add
ActiveSheet.Paste
Columns("A:H").Select ' this line is where it screws up
<-----rest of code irrelevant / snipped-----
End Sub
The macro literally dies the 5th line into the code (sometimes).
Suggestions??? Any help will be greatly appreciated. As I stated,
sometimes it runs like a scalded dog. Other times it dies there.
Thanks,
-Jon Pickens
|