<> vbNullString Then

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
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
In that case change Workbook to Sheet7
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,238
Messages
6,170,939
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top