title: How to add Computer Name and User name using VBA
body: <p>How can I use the computer name and username for each windows 7 and 10 computer on my network as variables to be entered into a table.</p>
  
  <p>I am using a Table on a hidden sheet to log saves to a workbook. The files are opened from and saved to a network computer. I'd like to know who saved on each workbook </p>
  
  <pre><code>Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
  
  Dim ws As Worksheet
  Set ws = Sheets("EDITS")
  Dim tbl As ListObject
  Set tbl = ws.ListObjects("Table1")
  Dim newrow As ListRow
  Set newrow = tbl.ListRows.Add
  
  'DIM SOME MORE OBJECTS
  Dim computername, username As String
  Dim ComputerNameLen As Long
  
  computername = Environ("computer name") 'Get computer name
  username = Environ("user name") 'Get user name
  
  
  SavePrompt.Show
  
  With newrow
      .Range(1) = Now
      .Range(2) = SavePrompt.TextBox1.Text
      .Range(3) = computername
      .Range(4) = username 
  
  End With
  
  Unload SavePrompt
  Unload computername
  Unload username
  End Sub
  </code></pre>
  
  <p>Range(1) &amp; Range(2) both fill out correctly but nothing appears for Ranges(3)&amp;(4)</p>
  
  <p>I think there is something wrong with my objects?</p>