keiserj
Board Regular
- Joined
- May 31, 2013
- Messages
- 89
Having to trouble getting this code to work. Used all last year and now always running debug and I'm struggling to figure out why?
Code:
Private Sub CommandButton1_Click()Dim ws As Worksheet
Dim shtname As String
Dim codes As String
If Workbook.TextBox1.Text <> vbNullString Then
MsgBox "Need SEQ# for Naming Tab", vbDefaultButton1
Application.ScreenUpdating = False
codes = TextBox2.Value
shtname = TextBox1.Value
On Error Resume Next
Set ws = ThisWorkbook.Sheets(ComboBox1.Value)
ws.Select
ws.Copy after:=Sheet11
ActiveSheet.Name = shtname
ActiveSheet.Rows("1:1").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
ActiveSheet.Range("A1:L1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
ActiveSheet.Range("A1:L1") = codes
On Error GoTo 0
End If
End Sub