@Tom van Stiphout ,
I tend to forget not everyone reads as easy as I do. Hope this way clears up any confusion. I am looking over the code you provided and can't help wondering if it really that easy. I was expecting more
code than four lines. I will plug this into my code. Thank you for your help and quick response.
Also to ensure that I fully understand how your code needs to be modified for my needs, please show where the changes need to be made. I will use corp.ds.thisisreallycool.com as an Active directory server in this case.
Private Sub cmdQuit_Click()
' removes from memory
Unload Me
End Sub
Private Sub cmdRecord_Click()
' Defines Varibles to be used
Dim iRow As Long
Dim LValue As String
Dim ws As Worksheet
Set ws = Worksheets("Renamed device")
' Searches for the next blank row for data entry
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
' Checks for a blank textbox and request data to be enter. Sets focus back on the textbox.
If Trim(Me.txtAsset.Value) = "" Then
Me.txtAsset.SetFocus MsgBox "Pease enter an serial number."
End If
' Rename the asset number to desired name based upon checkbox value.
' Modified to reflect change in naming convention. (2019)
With ws
If chkbxOutdoor.Value = False Then
Me.txtAsset.Value = WorksheetFunction.Substitute(txtAsset.Value, "ASUS", "ASUS-DK")
.Cells(iRow, 1).Value = Me.txtAsset.Text
Me.txtAsset.Value = "" Me.txtAsset.SetFocus
Else
lastfive = Right(Me.txtAsset.Value, 5)
LValue = "ASUS-LT" & lastfive .Cells(iRow, 1).Value = LValue
chkbxOutdoor.Value = False
Me.txtAsset.SetFocus
End If
' resets option buttons to false
optDOA.Value = False
optBOUNCER.Value = False
End With
End Sub
Private Sub cmdClear_Click()
' Clears the textbox of entered data and sets the focus back on the textbox
txtAsset.Value = ""
Me.txtAsset.SetFocus
End Sub
If optDOA.Value = True Then
.Cells(iRow, 3).Value = "Unit is Dead On Arrival"
Me.txtAsset.SetFocus
Elseif optBOUNCER.Value = True then
.Cells(iRow, 3).Value = "Unit returned unrepaired"
Me.txtAsset.SetFocus
End If
' ** planning to add **
If chkdomain.Value = False
Then
.Cells(iRow, 2).Value = "Not on Domain"
Me.txtAsset.SetFocus
Else
.Cells(iRow, 2).Value = "On Domain"
Me.txtAsset.SetFocus
End If