View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
K[_2_] K[_2_] is offline
external usenet poster
 
Posts: 557
Default SAME NAME FOR ALL SHEETS

Hi all, I have button on sheet which have macro allocated (see below)

Sub addsht ()
Sheets.Add After:=Sheets(Sheets.Count)
With ActiveSheet
..Name = "EXTRACTED DATA"
End With
End Sub

The problem is that when I press this button once it works fine but
when I press it again it gives error on
..Name = "EXTRACTED DATA"
what code line I can add so that when I press the button it give
sheets name like "EXTRACTED DATA (1) , EXTRACTED DATA (2) and so on.
in other words keeping the same name but adding 1 , 2 , 3..... in the
end. Please can any friend can help