Insert a row and paste value from user input

jcrook

New Member
Joined
Jun 12, 2020
Messages
15
Office Version
  1. 2016
Platform
  1. Windows
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.

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
Thank you in Advance,
Jay.
 

Attachments

  • Broach List.PNG
    Broach List.PNG
    37 KB · Views: 8
nevermind
I changed it to
ActiveSheet.Range("D3").Value = ToolName.

Thank you.
 
Upvote 0

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Glad you sorted it & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,455
Messages
6,124,938
Members
449,197
Latest member
k_bs

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