Solved

Run-time error 1004

Posted on 2009-04-08
4
265 Views
Last Modified: 2012-05-06
I am getting a run-time error in a script that i have used without incident in another file. This is just the piece of the script that is giving me issues. All it is supposed to do is clear out one tab, go to another tab, copy a variable range length, go back to the first tab and paste it as values.

There are no strings in any of the copy cells that are excessively large.

Nearly all the cells are formulas.

anyone?
Sub TableMaker()
 
' Clean out old data in "TableMaker" tab
    Sheets("TableMaker").Select
    Range("A8:K8").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Delete
    Range("a8").Select
    Application.CutCopyMode = False
    
'Copy Data to "Expansion Va-Vb"
    Sheets("Expansion Va-Vb").Select
    Range("A21:J21").Select <------------------------------------------This is where the error hits
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Sheets("TableMaker").Select
    Range("A8").Select
    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats
    Application.CutCopyMode = False
 
End Sub

Open in new window

0
Comment
Question by:mhjdowd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 59

Accepted Solution

by:
Saurabh Singh Teotia earned 250 total points
ID: 24098493
Have you place the code in the sheet module of your workbook, If yes then please change the same to the new module of the workbook..that is go to insert-->insert module and paste the code there and post that you wont face a error on the same.
Saurabh...
0
 
LVL 59

Expert Comment

by:Saurabh Singh Teotia
ID: 24098527
Alternatively you can use this code and it will do what you are looking for.
Saurabh..

Sub TableMaker()
 
' Clean out old data in "TableMaker" tab
Dim ws As Worksheet, ws1 As Worksheet
Set ws = Sheets("TableMaker").Select
Set ws1 = Sheets("Expansion Va-Vb").Select
    ws.Range("A8:K" & Cells(65536, "a").End(xlUp).Row).Delete
    ws.Range("a8").Select
    Application.CutCopyMode = False
    
'Copy Data to "Expansion Va-Vb"
    
    ws1.Range("A21:J" & ws1.Cells(65536, "a").End(xlUp).Row).Copy
    ws.Range("A8").PasteSpecial Paste:=xlPasteValuesAndNumberFormats
    Application.CutCopyMode = False
 
End Sub

Open in new window

0
 

Author Closing Comment

by:mhjdowd
ID: 31568092
Congratulations. This now ranks as my fastest time from question to complete solution on EE. You rock the house.
0
 
LVL 59

Expert Comment

by:Saurabh Singh Teotia
ID: 24098716
Lol@ its for sure a good feeling, Thanks for the same and grade.
Saurabh...
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question