Solved

Run-time error 1004

Posted on 2009-04-08
4
259 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
  • 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

932 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now