PDA

View Full Version : Solved: Last Row Array help



allison
04-04-2008, 06:54 AM
The code below works just fine, but I'm looking to make it more generic since additional teams could be added.

Currently, the team information is in I2:I9 - but if more are added, I don't want to have to change the code. How would I find the end of the array? I've tried the same what that I find the last row, but that's not working (probably because I screwed something up....!)

I'd apprecaite any help. Thanks!Sub Update_Team_Detail_Reports()
Dim DestBook As Workbook
Dim SrcBook As Workbook
Dim arr, i As Long

Application.ScreenUpdating = False
Set SrcBook = ThisWorkbook
SrcBook.Activate
With ActiveSheet
Sheets("Teams").Select
arr = Range("I2:I9").Value
End With
UserEntry = InputBox("What month is being reported?")
If UserEntry <> "" Then Range("A1").Value = UserEntry
For Each A In arr
On Error Resume Next
Set DestBook = Workbooks.Open("H:\Phone Information\Detail Team " & A & ".xls")
If Err.Number = 1004 Then
Set DestBook = Workbooks.Add
End If
On Error GoTo 0

DestBook.Activate
Sheets.Add.Name = UserEntry
DestBook.Save
DestBook.Close
Next

End Sub

mdmackillop
04-04-2008, 07:03 AM
arr = Range(Cells(2, "I"), Cells(2, "I").End(xlDown)).Value

allison
04-04-2008, 07:20 AM
thanks!!