ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with writting macro (https://www.excelbanter.com/excel-programming/346815-help-writting-macro.html)

nc

Help with writting macro
 
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.



chijanzen

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.




All times are GMT +1. The time now is 12:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com