Macro To Get Username
I have copied a macro off another board that get the username of the computer where the excel file is opened. It works fine on my pc but when I have sent the workbook to a colleague my username came up when he opened it. Also what I am trying to do is to modify the macro that does a vlookup on a range in worksheet 1 from where it picks name and surname (and transpose it onto worksheet 2 on cell A2), email (on B2), tel number (on C2) etc etc.
View Complete Thread with Replies
Related Forum Messages:
Find Username Match And Pull All Data At Same Row W/username
I have a thousand names on a column, and I have a several worksheet tabs as locations, such as CA, AZ, TX, and NY.
All names goes to main worksheet, show like this
apitchford 10 100 123
bkishpaugh 9 211 123
blee 14 234 111
cbonny 21 125 412
I need to pull a specific name, example, name = blee, move that name with all data on that row into TX.
I will need to set as automatically, becuase the names add and delete on the main worksheet, and will auto update those tab worksheets. (make sense?)
I have tried INDEX and MATCH, but they keep putting one data in, not all data.
Get Username & Computer Name Macro Code
why the Function & Property Get below is used to return the username and computer name when the Environ method does exactly the same in only two lines of code.
I would sooner use the Environ method but not if there is a valid reason why the function is used.
Private Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" ( _
ByVal lpBuffer As String, _
ByRef nSize As Long) As Long
Private Declare Function GetComputerName Lib "kernel32.dll" _
Alias "GetComputerNameA" ( _
ByVal lbbuffer As String, _
nSize As Long) As Long
Public Property Get UserName() As String
Dim stBuff As String * 255, lAPIResult As Long
Dim lBuffLen As Long
API To Get Username
I have Timesheet workbooks with 3 levels of access (user, viewer & me as developer).
I want use the GetuserName API function (with If/Then) to auto open the wkbk if I am loged in under my network login so psuecode looks bit like this
If network user is me then open wkbk
else ask for username & password
I have googled & searched the forum & the closest I have is this
Public Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function ReturnUserName() As String
' returns the NT Domain User Name
Dim rString As String * 255, sLen As Long, tString As String
tString = ""
On Error Resume Next...............
Get UserName Or Log In Name
I've got a sheet with a "Last Edited By:" field and I want this to be populated with the current users name i.e. I suppose I mean the user name that is assigned to Excel, as opposed to the XP log in... although I guess either would do. I'm OK on the change event thing, but just dont know the function to find the the current users name.
Insert Username Using VBA
I'm trying to use the code listed below on the works shared drive. When I open up the worksheet and save it, my log on identity is left as required in Cell B2 etc.. When someone else uses the sheet it just leaves the company name in this cell and not their log on identity? The date & time function always works ok. Can anyone advise me if what I'm after is achievable.
The code I've used below was used from a previous string on a similar question.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Range("A" & Rows.Count).End(xlUp).Offset(1).Value = Now()
Range("A" & Rows.Count).End(xlUp).Offset(0, 1).Value = Application.UserName
To Submit UserName & Password On IE
I'm trying to create a program that will automatically log in to a website that requires a username & password. I am able to enter the username and password in the correct text boxes, but I can not get the form to submit to approve the login. It refreshes and removes the password.
I have attached my code. The web url is inside it.
Dim ie As InternetExplorer
Dim ULogin As Boolean, ieForm
Dim MyPass As String, MyLogin As String
Set ie = New InternetExplorer
ie.Visible = True
'Loop until ie page is fully loaded
Do Until ie.ReadyState = READYSTATE_COMPLETE
VBA (IE Enter UserName And PassWord)
I am using the below code to access a website with IE.
My next step (of many) is to Login to this website.
The login screen requires that I enter:
How can I tell IE to enter my user name and Password?
' Macro recorded 2/6/2007 by dsggodwin
Public Sub Goto_ToyotaSupplier_Click()
Set EXP = CreateObject("InternetExplorer.application")
EXP.Visible = True
'put the webpage here
Unprotecting A Worksheet By Username
I would like to unlock the work sheet based on the username. However this code does not seems to be working.
The object is that only these users have access to the locked cells on a sheet and those users not on the list would only have access to the unlocked cells.
Incorrect Username For Workbook In Use
Usually when you try to open a file that someone else is using, it lets you know the file is in use, and lets you know who is using it. However, the situation I have is that when a user tries to open the file that is in use, it tells them that the file is in use, but gives them the wrong user who is using it!
For example, User1 opens the file and closes it again. User2 comes along and opens the file and stays in the file. User3 comes along and tries to open the file, but instead of saying User2 is using the file. It says User1 is using!
The file we have was originally built in Excel 97, but we using it through compatibility mode in Office 2007. The file is needed by various users, but putting it on shared access is not an option.
Web Query. Log On Username & Password
code below, I need :
1) navigate to a web page
2) submit my userId and password
3) beeing redirected to a different url I have to menage this situation for passing url to
4) quering sub
I am using Excel 2000 with win98
Error 429 Can't create object:which one?
Public Sub First()
Dim obEx As Object
Dim obj As New MSHTML.HTMLBody
Dim strPass As String
Dim elUid As New MSHTML.HTMLInputElement
Dim elPass As New MSHTML.HTMLInputElement
Dim elSubmit As New MSHTML.HTMLInputElement
Dim strUid As String
Dim Desc As String
Protect With Username VBA Content
i need a macro that will only open a file to certain users using the "get username" environ thing,
and only allow a list of users to access this file,
this will be a log of things that only managers whouls have access to, i have all the managers usernames (windows log ons) and what i need is that if the log on on the current machine, (the one currently opening the file) does not match one on th elist then the file should not open.
i could pasword protect the file but since my managers are kinda lazy and i wnat to show off a little (maybe hopefully that will push my promotion forward a couple of days at least)
Getting Username From System In A Cell
I am trying to get the username from the system to display in A1 in a file in Excel. I got this code form internet and put it in the sheet by clicking right mouse on the sheet1 tab and view code and then pasted it there.
Function UserNameWindows() As String
UserNameWindows = Environ("USRNAME")
And then as per the instructions on the same page I inserted this formula in A1 : =UserNameWindows()
The person stated that by doing this, I should be able to get user name displayed in A1. BUt all it gives me is #NAME?.
UserName For Access To Second Workbook
I have a problem with the Excel UserName & opening of a second xls File. Info:
The first file macro, looks as to the Excel UserName, and sets which worksheets from a second file in the network the person can see. then changes the Excel UserName to "helpdl", this is done because only 4 people have access to the Workbook on a network drive, see Code below (only the interesting part of the macro)
'Set the Excel UserName to "helpdl"
'(from Sub Change_UserName)
MyName = Application.UserName
OName = MyName
NewName = "HelpDL"
UserName = NewName
'Set the name of the Active File To "Slave"
Set wbSlave = ActiveWorkbook
'Open the Master from the Network (Wiesbaden server sv030100)
Workbooks.Open "\sv030100GruppenDL60116_MEWA Car Policy_Neukonzeption.xls"
'Set the name of the Active File to "Master"
Set wbMaster = ActiveWorkbook...........................
Get Username & Use To Change Directory
I have an Excel macro that pulls an external .txt file from a particular directory on a users computer. The directory is different for each user because of the way the computers are configured, see example below.
There is a system variable called %username% on each computer that can be used for navigation in an OS enviroment. So if you were at the command prompt on user's computer and typed cd\%username%work you would be put in the desired directory. Is there a way to leverage this system level variable, %username%, in an Excel macro?
Including Environment Username In Cell
I have searched the forum several way to resolve my issue and the only solutions were as follows:
Public Function UserName()UserName = Environ("username")UserName = Computer("UserName")End FunctionOption ExplicitFunction NetworkUserName() As StringDim responseNetworkUserName = Environ("Username")End Function
Problem is that I get a #REF! and #NAME? instead of the user names
I am using Excel 2000 (I can not upgrade, Government PC) plus we need it to support Excel 2000 - present versions.
Sorting Based On Category And Username
I have imported a list of information from a text file created by my network admin. I need to take the information from different categories in the list and sort them by category. All of the information is in once cell, but each has a common prefix (ie. URL = or Username), etc. After each prefix is the information I'd like to sort under the category (each category is the prefix). All of the information (prefix & data) is in cell A because it was a text file, and I'd like to simply find a way to say if A10 = URL= then place the information in C10...Below is what I need to sort.
URL = [url]
User Name =
Source IP = 0.0.0.0
Destination IP = 12.345.67.89
Disposition = CATEGORY_BLOCKED
Lookup Code = WISP_URL_BLOCKED
Category = Proxy Avoidance
Elapsed Time = 0 ms
AVG TIME PER REQUEST = 0 ms
URL = [url]
User Name =
Source IP = 0.0.0.0
Destination IP = 123.456.789.101
Disposition = QUOTA_USER_BLOCKED
Lookup Code = WISP_URL_BLOCKED
Category = Social Networking and Personal Sites
Elapsed Time = 0 ms
AVG TIME PER REQUEST = 0 ms
Check Username On File Start Up
i have a spreadsheet with the following worksheets:
"Data Entry" (sheet 1)
"Menu" (sheet 2)
"Username" (sheet 3)
In username the range a2:b5 contains the following:
a2= John b2=Write
where John or Scott are usernames in Environ("Username")
Is it possible to write a macro that does the following:
1. When the file is opened it looks at the network username and checks again the Username range in sheet3, if it is Write then the user can change cells in Data Entry and save the workbook, if Readonly then they can only view and not save, and if not there at all, then the worksheet closes.
2. When the file is opened write a log in a hidden sheet callled "Log" of the time opened and the username
3. Is it possible to do the same but making a copy of all cells changed ??
Enter Username & Password On Web Page
I am trying to log on to an FTP site and post a file through Excel VB. I have managed to open a new Explorer window and direct it to the URL, but I don't know what to do next. After navigation to the URL a Pop-Up Window comes asking for UserName and Password and I don't know how to supply it and click submit.
After I have completed that I will need to give the path of the file, click post, and close the window when it is done.
Here is what I got so far:
The commented out stuff is not working. I got it off a similar application that someone else in my company wrote that accomplishes a similar task.
Dim IE As InternetExplorer
Dim IEURL As String
Dim IEDoc As HTMLDocument
Set IE = CreateObject("InternetExplorer.Application")
Set IE = New InternetExplorer
IE.Visible = True
IEURL = "https://something.com" .................
Automate Username & Password Log In To Web Page
I'd like to automatically enter the username and password from a spreadsheet.
Currently, I've got a spreadsheet that has a login id in one cell and a password in an adjacent cell.
I click a button on the spreadsheet to call a hyperlink to a webpage while excell is using the copy function to copy the username to the clipboard.
Once the webpage loads, I just paste the username into the username box.
Then I go back to excel, copy the password, then back to the webpage and pastes the password.
This works good for me, but I'd like to make it a little bit better.
What I'd like to be able to do, if I had the username and password in one cell seperated by a symbol (say, "=" since usually don't use that one) then when I hyperlink to the webpage, I hit paste.
>> this time, when I hit paste, (maybe using some kind of a api code or something), excel pastes into the first box, *automatically* hits the [TAB] key, and paste the password.
Log UserName Of User On Data Entry
I have a spreadsheet where for traceability purposes, I get some vba to enter elsewhere on the sheet, the date and time that data is entered into a cell. Is it possible to also somehow capture the name of the person entering the data. We are on a network, so the pc does "know" which user is logged in.
Place Username In Directory Path
I've been trying to get the network username and found the solution on a previous thread. I have got to the point where I have copied the network username to my workbook. I now want to save this workbook into My Documents using that value for the username. So, so far i have:
'Get username from network
Dim User As String
CUser = Environ("username")
Cells(5000, 9) = Environ("username")
user = Application.ActiveCell
' Protect workbook and save in My Documents
ChDir "C:Documents and SettingsXXXXXXXMy Documents"
ActiveWorkbook.SaveAs Filename:= _
"C:Documents and SettingsXXXXXXMy DocumentsSalary Review Data 2007 - " & country & ".xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
The user who saves this workbook, will be doing so on their own PC's so i need the file to save to their 'My Documents' folder. So i need to replace the red X's with the user's network username (which I have extracted and dim'd as User. How do i write this into the path of the directory?
Unprotect Cell Based On Username Match
Sheets("sheet1").Range("a1").Value = Environ("username")
If Range("a1").Value = Range("H5").Value Then format.cell("c24")Protection=unlocked
I will have someone type in their supervisor's name in H5. When they send the form to their supervisor and A1 matches the entry in H5, I want cell c24 to be unlocked so the supervisor can make an entry.
Storing Username And Password Data In .txt File
I was able to get some help a while ago and hoping for someone to reply as well. Any one have ideas how to create a userform which will be use for username and password input? I know how to create one but is there anyway that the username and password will be stored as .txt file instead of using worksheet to store the data?
API To Retrieve A Webpage Needing Username And Password
I've been playing around with the API functions (specifically, InternetOpenURL) to retrieve the contents of an HTTP webpage and store the information within a text file, using Excel VBA. It works great for any "normal" webpage not requiring a "Username" and "Password" login. I can't find any examples on how this is done for a webpage requiring such a login? I've heard you can do this via sending the appropriate cookie to the server, but I can't find any documentation on the web? Does anyone have any idea on how this functionality is achieved?
Entering Correct Username Displays Colour
i have a username and password textbox and i want to know when i enter a correct username the textbox it is in turns green and when wrong it will turn red, here is the code i have so far im not very experienced but know bits and pieces.
Code for txtpassword.text
Display Username In Message Box That Has A File Open
I have bit of code that:
(1) opens another spreadsheet
(2) updates that spreadsheet
(3) saves that spreadsheet
(4) closes that spreadsheet
If the spreadsheet that requires updating is open by another user, I display a message indicating the file is open and no updates occured. There are about 20 persons within the organization that may have this file open? Is there away to display the username of the person who has the file open?.
Open Secure Website And Paste Username And Password.
Trying to find a set of code that I can use to open a website that's predetermined, and enter in the users name and password automatically. And if possible, open a new email via the website, addressed to a person, and ready to browse for the file to attach.
The code I have is below.
Private Sub CommandButton1_Click()
storenumber = [$c$3]
If [$iv$2] = True Then
If [$iv$3] 0 Then
MsgBox ("Can't send with No Adjustments Checked & Items to Adjust, Please clear one")
Get Username & Text From User To Use With Date & Time In Cell Comment
i have the following code to insert comments into cells, however if the user cancels the input box (i.e. doesn't insert any text), a comment is still added with their details and the comment 'FALSE'. Is there anyway to stop comments being added if the user cancels the input?
Dim iReply As Integer
Dim cl As Range
Dim sComment As String
Dim sText As String
Dim UserNameWindows As String
Automatically Add Username, Current Date And Time Each Tiime Any Cell Is Changed
I am looking to have a macro which will automatically add the username and date to a cell, when the cell above changes (or in this case =x). I have a bit of code from a previous project, but I have changed Target.Row to Target.Column and it is not behaving as I require:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range("B2:BZ2"), Target) Is Nothing Then
Range("C" & Target.Column).Value = Format(Date, "dd-mmm") & " " & Format(Time, "hh:mm") & " by " & (Application.UserName)
See the attachment for the example. What I need is whenever row 3 ="x" I need the corresponding cell in row "d" to update with the latest date, time and username. Please not the macro is currently not active on the sheet as i've added the ' character.
Conflict Between Auto Save&close Macro And Show/hide Sheets Macro
I am trying to make a save&close workbook macro.
I found several examples on google, but unfortunatly it conflicts with another macro I use for forceing users to enable macros (hide all sheets except one if macros are disabled).
The attached file is an example contaning the save&close code and the show/hide sheets depending on macros enabled.
If the file is opened with macros disabled then only one sheet will be visible.
If the file is opened with macros enabled other sheets are visible.
The problem if that this code uses a custom save, witch makes the save&close not save... (in module1 and in ThisWorkbook)
The pourpose of the save&close is to make sure some users don't forget the excel open and thus block access to it. So if a certain idele time passes excel has to save and close without any confirmation messages.
Userform To Control Macro Features. Macro = Search For File Type
I have a macro that I found somewhere on the net to look within a folder and list all the files of a certain file extension.
The macro to do this is in the attached example and is called 'Get_File_Names_Within_Dir_ext'.
I have created a basic userform outline, 'UF1' for the user to define:
Select File Extension
Select Folder to Search
I just don't have any idea how to sync the two.
If you type 'exe' into 'TB1_File_Extension' of 'UF1' the macro should search for '*.exe' files within the specified folder.
The search folder 'RefEdit1' box should open a windows explorer box (or some such) so that the user can select the directory in which to search for the previously specified file extension.
'TB2_Destination_Sheet' is a text box for the user to type the sheet within the workbook in which to list the files found within the specified directory.
'CB1_Find_Files' should activate the macro to find any files for the specified criteria.
There is also a Button 'Find File Types' in Sheet1 of the file which should activate the userform 'UF1'.
Worksheet Change Macro Takes Too Much Time When Run With Update List Macro
I have a worksheet in which I have a worksheet_change macro. This worksheet_change macro makes sure that a few cells will keep their colors, even if the user copies and pastes a new value to that cell. This worksheet_change macro runs each time there is a change on the worksheet. Now my problem is that on the same sheet I have an update list macro which updates around 20.000 rows and two columns (which is alltogether around 40.000 values) and it takes a while to run. So.. it takes a loooooooooot of time (too much) when these two macros both run.
My question is that can I somehow disable the worksheet_change macro while the update list macro runs. I mean something like when I start the update list macro to disable worksheet_change macro and when the update list macro finishes, then reenable worksheet_change macro?
If Statement In Macro: Macro To Change A Range Of Cells Colours Based On A Single Cell?
1st - Need a macro to change a range of cells colours based on a single cell having a value greater than 0.001. ie. cells A1 - G1 need to change to grey based on cell F1 having a value greater than 0.001 entered in it?
2nd - Also a macro for deleting the text contents of cell C1 based on cell F1 having a value greater than 0.001. Therefor if cell F1 has a number greater than 0.001 it changes the colour of celss A1 - G1 and also deletes the text in cell C1?
Macro Doesn't Work On Button, But Fine From Macro Menu!
I've recorded a macro that copies an entire tab into a new spreadsheet then goes on the copy and paste information from one tab to another.
When I run the macro from the Tools>Macros menu it works perfectly.
But when I copy the code and add it to that of a button it fails and posts the following error: Run-time error '1001': Select method of Range class failed.
The first attachement shows the code for the macro as it is alone, and the second shows how I simply copied and pasted it into the 'view code' window of the button.
Needless to say I'm a beginner at macros and only every record them, I can usually make stuff work that way but this has me stumped!
Macro Stops Running The Macro Completely And Hangs In The Middle
Here in our department we made a pretty elaborate macro that takes a report and sorts them out to 17 different sheets in a one workbook. This Macro pulls a file from a specific location on our server and then opens the CSV sorts it out color codes all the important information and saves it back onto the server under you specific initials.
They are four PC's along with our Managers laptop that run this Macro daily.
About 3 weeks ago my Managers laptop stops running the Macro completely and hangs in the middle of the whole thing. Eventually crashing Excel.
We try to remove the modules and re-import them back into the personal macro workbork but this does not work. The Macro's did not change and still fully function on the other four desktops to this day.
I uninstall Office on my Managers laptop and reinstall. Import the Modules again and still hangs up in very same spot it did 3 weeks ago.
I've tried to lower the macro security to the lowest level also and I've still had no luck with this laptop. I don't understand. The Macro's function perfectly on other PC's but will not function on this laptop.
Delay Macro (Put In A Statement Within A Macro That Populates Cells With The Values)
Put in a statement within a Macro that populates cells with the values that I want it to but instead of populating all at the same time, is it possible for the values to be delayed.
I have designed a mock spreadsheet (attached) it has two columns 'Before' and 'After'
After = Before values (in this mock)
When you press the button, the values are populated straight into the 'After column' can we add the delay between the values? So that the values dont come up straight away.
Macro Disable/enable Still Appears After Macro Deleted From Workbook
I have a question concerning Macros and the Disable/Enable prompt. My boss has a spreadsheet which has been used for years and he recently wanted to and did remove the macros from the spreadsheet (they were no longer necessary), but the disable/enable prompt still appears when the spreadsheet is opened. I replicated this in a test spreadsheet with a simple insert line macro and received the same results. Is there a way to remove the macros and the disable/enable prompt once they are removed? I know about setting the security to low to not see the prompt, but I would think that once the macros are deleted, the prompt should not appear any more.
Macro To Delete Vba Code - Macro Security Warning
I have recently grabbed the very helpful "Macro to delete VBA code" from this site, and it's working but with one small problem.
My worksheet runs a lot of code, then deletes all macro code and saves itself.
The problem is the next time i open I still get the macro security warning!
I've checked thoroughly and there is definatley no vba left anywhere.
If I open the document, enable macros, and save it, then open it again, I no longer get the warning.
Macro - Repeat Macro A Specific Number Of Times
I have created a macro that copies the outcome of a specific calculation (that is driven by random numbers) and pastes it (as values) into a seperate table. It then recalculates the sheet, copies the new outcome and pastes it into the same table at a row beneath the previous one.
However, I would like to be able to determine how many times this loop is repeated (i.e. how many rows of outcomes will be generated) without having to change the macro each time. Is this possible? Maybe by just linking it to a cell where the number of outcomes/repeats is specified.