lostitagain
New Member
- Joined
- Jul 5, 2012
- Messages
- 21
Running Excel 2010
Here is my code:
This code copies a template to a worksheet from a different workbook. Each template has a named range and the one chosen is determined by the variable 'NumHeads'.
Whenever I run the program I get a Runtime Error 1004 Method Goto of object application failed.
Info is a custom class that I created and it works fine with all other modules
It worked properly for a few minutes and then randomly quit working. I think the problem is either in the assigning a value to the FromRange variable or in the Application.Goto statement.
Any help is appreciated
Here is my code:
Code:
'Select the correct Range to copy and copy into the sheet
Set FromRange = Workbooks(Info.FromBook).Worksheets(TEMPLATESHEET).Range(NumHeads)
Set ToRange = Workbooks(Info.ToBook).Worksheets(Info.ToSheet).Range("A" & RowTo)
'Copy the template
Application.Goto FromRange
Selection.Copy
Application.Goto ToRange
Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Worksheets(Info.ToSheet).Paste
FromRange = Workbooks(Info.FromBook).Worksheets(Info.RuleSet).Range("E" & FoundRow)
This code copies a template to a worksheet from a different workbook. Each template has a named range and the one chosen is determined by the variable 'NumHeads'.
Whenever I run the program I get a Runtime Error 1004 Method Goto of object application failed.
Info is a custom class that I created and it works fine with all other modules
It worked properly for a few minutes and then randomly quit working. I think the problem is either in the assigning a value to the FromRange variable or in the Application.Goto statement.
Any help is appreciated