Create seperate xls files with names based on cell text

T

TroyB

Hi,
I've got a summary worksheet where the user inputs all the relevant "input"
information. I'd like to create a macro that uses all the information in
column B (ie B2 = 1111, B3 = 1112, B4=1113 etc ) and create individual
workbooks titled 1111.LC.xls, 1112.LC.xls, 1113.LC.xls etc and have them
saved in a directory I:\Invoices\

What is the code i need to accomplish this?
Thanks in advance. These newsgroups are great!
Troy
 
R

Rob van Gelder

Sub test()
Const cPath = "I:\Invoices\"

Dim wkb As Workbook, i As Long, lngLastRow As Long

With ActiveSheet
lngLastRow = .Cells(Rows.Count, 2).End(xlUp).Row
For i = 2 To lngLastRow
Set wkb = Workbooks.Add
wkb.SaveAs cPath & .Cells(i, 2).Value
wkb.Close
Next
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top