Hi all!
The below code works perfectly, but now I'm also trying to capture the username (To the left of the data, in column A) of the person who pressed the save button.
I found this code and it works well - I can enter "GetName(1)" in a cell, and it populates my name. But I'm having a hard time altering the code above to populate the users name in the same range as above, in column A. Tried a handful of different ways, but I think I may be taking the wrong approach.
Any help combining these would be appreciated! Thanks so much!
The below code works perfectly, but now I'm also trying to capture the username (To the left of the data, in column A) of the person who pressed the save button.
VBA Code:
Sub SaveBulk()
Application.EnableEvents = False
Application.ScreenUpdating = False
With Sheets("Output_Bulk")
Dim FirstEmptyRow As Long
FirstEmptyRow = .Cells(.Rows.Count, "D").End(xlUp).Offset(1, 0).Row
Sheets("Main").Range(Sheets("Admin").Range("G5") & ":" & Sheets("Admin").Range("G6")).Copy
.Cells(FirstEmptyRow, "D").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
Excel.Application.CutCopyMode = False
End With
Application.ScreenUpdating = True
Application.EnableEvents = True
MsgBox "Bulk Saved"
End Sub
I found this code and it works well - I can enter "GetName(1)" in a cell, and it populates my name. But I'm having a hard time altering the code above to populate the users name in the same range as above, in column A. Tried a handful of different ways, but I think I may be taking the wrong approach.
Any help combining these would be appreciated! Thanks so much!
VBA Code:
Option Explicit
Function GetName(Optional NameType As String) As String
Application.Volatile
If Len(NameType) = 0 Then NameType = "OFFICE"
Select Case UCase(NameType)
Case Is = "OFFICE", "1"
GetName = Application.Username
Exit Function
Case Is = "WINDOWS", "2"
GetName = Environ("UserName")
Exit Function
Case Is = "COMPUTER", "3"
GetName = Environ("ComputerName")
Exit Function
Case Else
GetName = CVErr(xlErrValue)
End Select
End Function