View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
chijanzen chijanzen is offline
external usenet poster
 
Posts: 139
Default Help with writting macro

nc:

If data in a A column

try,

Dim wbk As Workbook
With ThisWorkbook.Sheets("Sheet1")
rPath = ThisWorkbook.Path
i = 2
Do While .Cells(i, "A") < ""
Set wbk = Workbooks.Add
wbk.Sheets("Sheet1").Range("A1") = .Cells(i, "A")
wbk.SaveAs Filename:=rPath & "\" & .Cells(i, "A")
wbk.Close
i = i + 1
Loop
End With

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"nc" wrote:

Hi
I have a list of code eg. AH100, AH200 etc. in a column on a worksheet with
a field name 'StaffIDNo'. I would like to create a workbook for each code,
with the code in a specified cell A1 e.g AH100, and the workbooks are saved,
'code' Time allocation schedule.xls e.g AH100 Time allocation schedule.xls
in the same specified folder.

Thanks.