Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Assign cell value from VBA function
Hello,
Please help out a newbie. How can I assign a cell value from a VBA function? I have the following in my VBA code: Private Sub Workbook_Open() MsgBox username() End Sub ' Return the user's name. Public Function username() As String Const UNLEN = 256 ' Max user name length. Dim user_name As String Dim name_len As Long user_name = Space$(UNLEN + 1) name_len = Len(user_name) If GetUserName(user_name, name_len) = 0 Then username = "<unknown" Else username = Left$(user_name, name_len - 1) End If End Function This works fine for displaying the Msgbox, but I'd like to put the username in a specific spreadsheet cell. Any help is appreciated. Eri -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Assign cell value from VBA function
Found what I needed.....
Private Sub Workbook_Open() 'MsgBox username() Sheets("Sheet1").Cells(1, "A") = username() End Su -- Message posted from http://www.ExcelForum.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Assign a function to a Command Button | Excel Worksheet Functions | |||
Assign Function to a Command Button | Excel Discussion (Misc queries) | |||
Can I Assign A User Defined Function To A Cell? | Excel Worksheet Functions | |||
Assign the cell address with a function | Excel Worksheet Functions | |||
Assign cell value from VBA function | Excel Programming |