Add Worksheet via VBA

Add Worksheet via VBA

Postby kawstov » Thu Aug 14, 2014 2:19 pm

The following code on a button would do the trick:

Code: Select all
Sub Button1_Click()
Dim inputdata
  ' Get the data
  inputdata = Application.InputBox("Enter your sales ID:", "Input Box Text", Type:=0)
  inputdata = Left(inputdata, Len(inputdata) - 1)
  inputdata = Right(inputdata, Len(inputdata) - 2)
  'MsgBox (inputdata)
  If Len(inputdata) > 31 Then
    MsgBox ("Text more than 31 characters")

    Else: Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = inputdata
  End If
End Sub
Add Worksheet.xlsm
Make sure you enable the macros
(16.12 KiB) Downloaded 477 times
Site Admin
Posts: 119
Joined: Tue May 28, 2013 10:51 pm

Return to Excel

Who is online

Users browsing this forum: No registered users and 1 guest