Error code 1004

Girox8

New Member
Joined
Jan 29, 2017
Messages
2
Hi,

I used an existing macro that should be working but it doesn't anymore neither does the one below.

Code:
        Dim x As Integer
        Dim i As Integer
        
        x = 1
        For i = 0 To 15
        
        Range("c4").Value = (x + i)
                    
        Sheets("feuil1").Select
        PathName = Range("D3").Value
        Filename = Range("D4").Value
        TabName = Range("D5").Value
        ControlFile = ActiveWorkbook.Name
        Workbooks.Open Filename:=PathName & Filename
        ActiveSheet.Name = TabName
        Sheets(TabName).Copy After:=Workbooks(ControlFile).Sheets(1)
        Windows(Filename).Activate
        ActiveWorkbook.Close SaveChanges:=False
        Windows(ControlFile).Activate
        
        Sheets("feuil1").Select
        TabName2 = Range("D6").Value
        Workbooks.Open Filename:=PathName & Filename
        ActiveSheet.Name = TabName2
        Sheets(TabName2).Copy After:=Workbooks(ControlFile).Sheets(1)
        Windows(Filename).Activate
        ActiveWorkbook.Close SaveChanges:=False
        Windows(ControlFile).Activate
        Sheets("feuil1").Select
        
        Next i
        
        Range("c4").Value = 0
    
    End Sub

I know the second part is probably incorrect, but the first one is from the existing code so it should be working fine.

What is the problem?

Thanks for reading!
 
Last edited by a moderator:

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,215,510
Messages
6,125,234
Members
449,216
Latest member
biglake87

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top