Check the Active Directory Server for the remote computer name


New Member
Oct 22, 2020
Office Version
  1. 365
  1. Windows
  2. Mobile
I am not exactly sure if this is the correct area to post this question. A bit of the backstory is I am attempting to code in VBA a small macro/program that does three things. Two of these I have got working correctly. The third one is proving to be a bit harder to get going as I have not been able to find any useful information about what I am trying to do. What the macro/program does is take the serial number scanned or keyed in, rename it the correct format for imaging and deployment based on machine type. What I having issues with is getting it verified on the domain server without manually checking. It becomes a problem when I have 6000+ units to verify. I am looking for a way to add to my code a few lines to allow excel to check and see if the computer is listed on the domain. I have copied and pasted some of my code to help.

Private Sub cmdRecord_Click()

' Defines Varibles to be used
Dim iRow As Long
Dim LValue As String
Dim ws As Worksheet
Dim NameCheck As String
Set ws = Worksheets("Renamed Units")

' 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
MsgBox "Pease enter an asset 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, "PU3W", "DSK-AP")
.Cells(iRow, 1).Value = Me.txtAsset.Text
NameCheck = Me.txtAsset.Text
Me.txtAsset.Value = ""
lastfive = Right(Me.txtAsset.Value, 5)
LValue = "LAP-TOP" & lastfive
.Cells(iRow, 1).Value = LValue
chkbxOutdoor.Value = False
NameCheck = LValue
Me.txtAsset.Value = ""
End If

' Check the Active Directory Server for the remote computer name

Here I need code that will allow the variable NameCheck be used to is if the computer name is on the domain.

End With

Some videos you may like

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type


Well-known Member
Feb 24, 2003
Office Version
  1. 2016
  2. 2013
  3. 2011
  4. 2010
  5. 2007
  1. Windows
Hi and welcome
my thoughts would be given the list in AD is going to be 99% static I would export the group from AD and then import it into excel by going to the group and choose export
you could then just do a simple lookup on your list in excel
the lookup could be refreshed as and when multiple changes are made in AD
its a few years since I have used vba and excel against AD but I will see if I can find any of my code to see if it does help in connecting directly

Watch MrExcel Video

Forum statistics

Latest member