procedure too large while running code

vinod9111

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

Receiving the procedure larage while running the below code.

Request you to please point out the error i have done while compiling from the below code

Dim dist As Range, curwbk As Workbook, newwb As Workbook, filname As String, foldername As String
With Application
.ScreenUpdating = False
.DisplayAlerts = False
End With
filname = Worksheets("Inputs for LDM").Range("a1").Value
foldername = Sourcewb.Path & "\" & Worksheets("Inputs for LDM").Range("b1").Value
MkDir foldername
Sheets("Main Sheet to Enter Details").Select
Range("e4").Select
For Each dist In Range("distname")
[distname] = dist.Value
DoEvents
Set curwbk = ActiveWorkbook
Sheets(Array("Inputs for LDM", "City Level Target", " District Level Target")).Copy
Set newwb = ActiveWorkbook
With ActiveSheet.UsedRange
.Value = .Value
End With
newwb.SaveAs foldername & "\" & filname & ".xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
Range("a1").Select
newwb.Close
Next
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub


regards
Vinod
using excel 2007
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
That proc is not too long, something else must be problematic here, or you are not showing all code in your module. How many lines is the module long?
 
Upvote 0
Hi Jan,

The Macro is working but the issue am facing is that, it is not updating the respective distirct information while generating the file.

can you help, pasted below code for reference.

Sub ACP()
Dim dist As Range, curwbk As Workbook, newwb As Workbook, filname As String, foldername As String, statename As String
With Application
.ScreenUpdating = False
.DisplayAlerts = False
End With
statename = Worksheets("Inputs for LDM").Range("b1").Value
foldername = "D:\Temp\" & statename
MkDir foldername

Sheets("Main Sheet to Enter Details").Select
Range("e4").Select
For Each dist In Range("distname")
[distvalue] = dist.Value
DoEvents
filname = Worksheets("Inputs for LDM").Range("a1").Value
statename = Worksheets("Inputs for LDM").Range("b1").Value
Set curwbk = ActiveWorkbook
Sheets(Array("Inputs for LDM", "City Level Target", "District Level Target")).Copy
Set newwb = ActiveWorkbook
With ActiveSheet.UsedRange
.Value = .Value
End With
newwb.SaveAs foldername & "\" & filname & ".xls", FileFormat:=xlExcel8, CreateBackup:=False
Range("a1").Select
newwb.Close
Next
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub


regards
Vinod
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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