nickwilshaw
New Member
- Joined
- Apr 18, 2011
- Messages
- 13
Hi Guys,
I need sonme help with VBA code so as to add sheets to a workbook per the contents of a list ( a column in a sheet).
For Example, say sheet "Customers" contains 25 customer names in Column A - eg A,B,C,D etc then I would want 25 sheets to be added and for those sheets to be named A,B,C,D etc.
Thus far, I have been trying to develop:
Sub NameWorksheet()
Range("A2").Select ' cos A1 is the header "Customer"
Do While IsEmpty(Sheets("Customer").Range("A2").Offset(0, 1)) = False
Sheets.Add.Name = ActiveCell.Text
ActiveCell.Offset(1, 0).Select
Loop
End Sub
However, a principal stumbling block is the
Sheets.Add.Name = ActiveCell.Text as VBA want a range, say, ="A2" rather than = ActiveCell.
Equally, I may be approaching this the wrong way and any pointers would again be most appreciated.
Best regards and many thanks
Nick
I need sonme help with VBA code so as to add sheets to a workbook per the contents of a list ( a column in a sheet).
For Example, say sheet "Customers" contains 25 customer names in Column A - eg A,B,C,D etc then I would want 25 sheets to be added and for those sheets to be named A,B,C,D etc.
Thus far, I have been trying to develop:
Sub NameWorksheet()
Range("A2").Select ' cos A1 is the header "Customer"
Do While IsEmpty(Sheets("Customer").Range("A2").Offset(0, 1)) = False
Sheets.Add.Name = ActiveCell.Text
ActiveCell.Offset(1, 0).Select
Loop
End Sub
However, a principal stumbling block is the
Sheets.Add.Name = ActiveCell.Text as VBA want a range, say, ="A2" rather than = ActiveCell.
Equally, I may be approaching this the wrong way and any pointers would again be most appreciated.
Best regards and many thanks
Nick