Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 02-07-2015, 10:53 PM
excelledsoftware excelledsoftware is offline Insert Sheet via cell value Windows 7 64bit Insert Sheet via cell value Office 2003
IT Specialist
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

If you want to add a worksheet and then give it the name of the active cell the code below will do that.

Code:
Sub CreateNamedWorksheet()
  Dim wb As Workbook, nws As Worksheet, NewName As String
  Dim ws As Worksheet, cws As Worksheet
  
  Set wb = ThisWorkbook
  Set cws = wb.ActiveSheet
  If ActiveCell.Value <> "" Then
    NewName = ActiveCell.Value
    For Each ws In wb.Worksheets
      If ws.Name = NewName Then
        MsgBox ("The name " & NewName & " is already in use. No new worksheet added.")
        End
      End If
    Next ws
    Set nws = wb.Worksheets.Add
    nws.Name = NewName
  Else
    MsgBox "The active cell has no value to name the new worksheet"
    End
  End If
  cws.Activate  'Use a ' right before this line to select the new worksheet.
 
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Sheet via cell value Help Coloring a cell in Sheet one if data is missing from another sheet Aeducan Excel 1 06-22-2014 04:49 PM
Insert Sheet via cell value How to set a hyperlink from a pp presentation into a CELL from an excel sheet Sabi PowerPoint 1 04-30-2013 06:36 AM
Insert Sheet via cell value Insert Excel sheet markg2 Word 1 12-15-2010 12:19 PM
copy cell from sheet 2 to sheet 3 macro slipperyjim Excel Programming 1 02-18-2010 01:31 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:17 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft