Create a new worksheet (excel 2003) if one or more cells in arange is not empty
On Nov 20, 2:59*pm, jason wrote:
On Nov 20, 2:17*pm, "Luc Ferrari" wrote:
I want to create a new "tab, worksheet or whatever you call it " (in excel
2003) if one or more cells in a range contain a value.
The code starts after i hit a "button".
And name the sheet after the value of the cell left of the first cell of
that range.
I have no clue in how to program this.
Can someone provide me the code for this....
Thanks for your help
Luc
a finite range? ie: cells A1:A20 or an infinite range?
if finite:
sub A()
dim i
for i=1 to 20
*if thisworkbook.activeshees.cells(i,1)<"" then
* * *thisworkbook.sheets.add.name= * * thisworkbook.sheets.cells(i,
1).value 'or thisworkbook.sheets.cells(i,1).text
end if
next i
this should work.
EDIT:
sub A()
dim i
for i=1 to 20
if thisworkbook.activeshees.cells(i,1)<"" then
thisworkbook.sheets.add.name= thisworkbook.sheets.cells(i,
1).value 'or thisworkbook.sheets.cells(i,1).text
exit sub
end if
next i
the above code will add one worksheet per non-empty cell. this will
add only one for the first non-empty value found in cells A1:A20
|