Hello,
This is extremely simple but I can't find an example on this board. I'm sure it exists.
I want to get user input on a tool number in the form of alphanumeric. This works ok.
I then Uppercase the letters. This works.
I then check if a worksheet already exists with the name of the tool number. This works.
If there's NOT a sheet, then a new one is created by copying a template and renaming the sheet. This works.
I then want to check the list of tool numbers starting at B9 to the end and insert the tool number alphanumerically. This is NOT working.
Any suggestions would be greatly appreciated.
Thank you in Advance,
Jay.
This is extremely simple but I can't find an example on this board. I'm sure it exists.
I want to get user input on a tool number in the form of alphanumeric. This works ok.
I then Uppercase the letters. This works.
I then check if a worksheet already exists with the name of the tool number. This works.
If there's NOT a sheet, then a new one is created by copying a template and renaming the sheet. This works.
I then want to check the list of tool numbers starting at B9 to the end and insert the tool number alphanumerically. This is NOT working.
Any suggestions would be greatly appreciated.
VBA Code:
Option Explicit
Private Sub CommandButton1_Click()
Dim toolName As Variant
Dim i As Integer
Dim lastRow As String
Dim lastOpenCell As Integer
Dim rngCell, testRange As Range
toolName = InputBox("Enter Tool Serial Number." & vbCrLf & _
"Upper or Lower Case letters.")
If toolName = "" Then
MsgBox "Operation Cancelled"
GoTo 999
Else
toolName = StrConv(toolName, vbUpperCase)
End If
'Range("D11").Value = toolName - Passed 6/29/2020
Sheets("Start Sheet").Activate
lastRow = Range("B" & Rows.Count).End(xlUp).Row
'Range("D11").Value = lastRow 'Passed 6/29/2020
'testRange = Range("B9: & lastRow")
lastOpenCell = lastRow + 1
'Check if worksheet already exists - Passed 6/29/2020
For i = 1 To Worksheets.Count
If Worksheets(i).Name = toolName Then
MsgBox "A worksheet " & toolName & " Exists!" & vbCrLf & "Operation Cancelled."
Sheets(toolName).Select
GoTo CheckList
End If
Next i
CheckList:
'Add toolName to list on Start Sheet - Not Passed 6/29/2020
Worksheets("start Sheet").Activate
For Each rngCell In Range("B9: & lastRow")
If Cells(rngCell).Value > toolName Then
Cells(rngCell).Select
toolName.Copy
Range(rngCell).EntireRow.Insert
End If
Next rngCell
'Create a worksheet "toolName" and copy template worksheet - Passed 6/29/2020
ThisWorkbook.Worksheets("Template").Copy After:=Worksheets(Sheets.Count)
Worksheets(toolName).Activate
999 End Sub
Jay.