run 1004 errror

vinod9111

Active Member
Joined
Jan 21, 2009
Messages
426
Hi all,

Am trying to write a code which will filter in a sheet which contains data, copy the data basis the district and paste to the second sheet which is again linked to the ouput sheet i.e. the third sheet, copy the third sheet as new work book and save it. Run the macro till the last district.

Below is the code but i am getting run 1004 error, any help would be appeciated

Sub multplrept()
Dim dist As Range, curwbk As Workbook, newwb As Workbook, My_Range As Range, filname As String, Lastrow As Long
With Application
.ScreenUpdating = False
.DisplayAlerts = False
End With
Lastrow = Sheets("GIST").Cells(Rows.Count, 3).End(xlUp).Row
filname = Worksheets("Place Outstanding").Range("F2").Value
Set My_Range = Range("A1:F" & Lastrow)
Set curwbk = ActiveWorkbook
For Each dist In Range("fipdist")
[fipdistname] = dist.Value
DoEvents
Sheets("GIST").Select
My_Range.AutoFilter Field:=2, Criteria1:="=" & [fipdistname].Value
My_Range.Parent.AutoFilter.Range.Copy
Sheets("Place Outstanding ").Select
Range("c5").Select
Selection.PasteSpecial Paste:=xlPasteValues, operation:=xlNone, skipblanks:=False, Transpose:=False
Sheets("FIP").Copy

Set newwb = ActiveWorkbook
With ActiveSheet.UsedRange
.Value = .Value
End With
Range("a1").Select
newwb.SaveAs filename:="D:\FIP" & filname & ".xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
newwb.Close False
Next
With Application
.ScreenUpdating = True
.DisplayAlerts = True
End With
End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

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