sumit Madaan
New Member
When i am running this code, same is going break in the mid and then again i have change the range of loop and loop runs.
but i am not able to understand why it is breaking in the Mid.
Loop is 2 to 39, sometimes it breaks in 14, sometimes 16, sometimes 19 etc.. every time loop break once when i run this code.
Please help.
MOD EDIT: CODE Tags were added.
but i am not able to understand why it is breaking in the Mid.
Loop is 2 to 39, sometimes it breaks in 14, sometimes 16, sometimes 19 etc.. every time loop break once when i run this code.
Please help.
Code:
sub FILE_RH()
'
' copy Macro
'
' Keyboard Shortcut: Ctrl+Shift+Q
'
For i = 2 To 39
Dim r As Range
Set r = Selection
Workbooks("MasterBBG - Copy").Sheets("Data").Activate
Range(Selection, Selection.End(xlToRight)).Select
Selection.AutoFilter
Range("A1").Select
Sheets("Data").Range("$A$1:$AI$200000").AutoFilter Field:=31, Criteria1:=Sheet3.Range("a" & i).Value
Range("$A$1:$AI$200000").Select
Range("A1").Activate
Selection.SpecialCells(xlCellTypeVisible).Select
Range("$A$1:$AD$200000").Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.SaveAs Filename:= _
"C:\Users\ibl63122\Desktop\New folder\" & Sheet3.Range("d" & i).Value, FileFormat:= _
xlExcel12, CreateBackup:=False
ActiveWorkbook.Close
Workbooks("MasterBBG - Copy").Sheets("sheet1").Activate
ActiveWorkbook.EnvelopeVisible = True
With r.Parent.MailEnvelope.Item
.To = Sheet3.Range("b" & i).Value
.cc = Sheet3.Range("C" & i).Value
.bcc = ""
.Subject = "Portfolio Position of " & Sheet3.Range("a" & i).Value
.attachments.Add "C:\Users\ibl63122\Desktop\New folder\" & Sheet3.Range("d" & i).Value
.send
Kill "C:\Users\ibl63122\Desktop\New folder\" & Sheet3.Range("d" & i).Value
End With
Next i
End Sub
MOD EDIT: CODE Tags were added.
Last edited by a moderator: