Hi
I'm trying to get my code to copy & paste some data onto a new workbook, remove and resize some columns, save and close the workbook and then select the next name from a dropdown menu and repeat the process until the end of the list is reached. Whilst I've achieved most of it I'm stuck at the looping the whole module.
Below is my code, any help would be greatly appreciated;-
Sub IndvReport()
'
' IndvReport Macro
'
'
Workbooks.Add
Application.DisplayAlerts = False
Application.WindowState = xlMaximized
ChDir _
"U:\Housing\CSC and CEX Admin Centre\CSC\CSC Reports\Agents Stats\Weekly\Individual Reports"
ActiveWorkbook.SaveAs filename:= _
"U:\Housing\CSC and CEX Admin Centre\CSC\CSC Reports\Agents Stats\Weekly\Individual Reports\Book1.xlsx" _
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
Windows("Test Weekly Agent Stats.xlsm").Activate
Cells.Select
Selection.Copy
Windows("Book1.xlsx").Activate
ActiveSheet.Paste
Application.WindowState = xlMaximized
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Columns("B:D").Select
ActiveSheet.Shapes.Range(Array("Straight Arrow Connector 1")).Select
Selection.Delete
Range("C1:F2").Select
Range("F1").Activate
Application.CutCopyMode = False
Selection.ClearContents
Range("A1:A2").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateInputOnly, AlertStyle:=xlValidAlertStop, Operator _
:=xlBetween
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Columns("B:D").Select
Selection.Delete Shift:=xlToLeft
Columns("C:F").Select
Selection.Delete Shift:=xlToLeft
Columns("J:K").Select
Selection.Delete Shift:=xlToLeft
Columns("L:L").Select
Selection.Delete Shift:=xlToLeft
Range("N:Q,T:W,AB:AH").Select
Range("AB1").Activate
Selection.Delete Shift:=xlToLeft
Columns("Z:AC").Select
Selection.Delete Shift:=xlToLeft
Columns("S:S").EntireColumn.AutoFit
Columns("T:T").EntireColumn.AutoFit
Columns("X:Y").Select
Selection.Delete Shift:=xlToLeft
Range("B3").Select
Selection.Copy
Range("B3:D3").Select
ActiveSheet.Paste
Range("G28").Select
Application.CutCopyMode = False
Range("A1:A2").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Dim Path As String
Dim filename As String
Path = "U:\Housing\CSC and CEX Admin Centre\CSC\CSC Reports\Agents Stats\Weekly\Individual Reports"
filename = Range("A1")
ActiveWorkbook.SaveAs filename:=Path & filename & ".xls", FileFormat:=xlNormal
ActiveWindow.Close
Dim dv As Validation
Dim vaSplit As Variant
Dim i As Long
Set dv = ActiveCell.Validation
vaSplit = Range(dv.Formula1).Value
For i = LBound(vaSplit, 1) To UBound(vaSplit, 1)
If vaSplit(i, 1) = ActiveCell.Value Then
If i < UBound(vaSplit, 1) Then
ActiveCell.Value = vaSplit(i + 1, 1)
Exit For
End If
End If
Next i
Application.DisplayAlerts = True
End Sub
Bookmarks