[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VB environ

Posted on 2010-11-28
12
Medium Priority
?
529 Views
Last Modified: 2012-05-10
Is is possible to replace the dropdown (Logged by) in the useform?

I was wondering if the computers username could be automatically displayed (Environ). It would just pick up the name of the PC as opposed to selecting a name in the dropdown.



userform.xls
0
Comment
Question by:Gazza83
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 45

Assisted Solution

by:patrickab
patrickab earned 664 total points
ID: 34227013
Try:

TextBox1.Text = Environ("Username")
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34227054
I would also suggest changing the .Locked property to true so that no one can change anything in that textbox....
0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 34227201
I think he wants Environ("ComputerName")
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 37

Expert Comment

by:TommySzalapski
ID: 34227325
For future reference, pull up a command prompt and type SET and it will give you a list of all the environment variables currently in the system. I use this a lot because I always forget what they are all called.
0
 

Author Comment

by:Gazza83
ID: 34227327
Yeap would like to lock the cell down, have been experimenting with altering the existing code but no joy yet.

0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 34227380
Lock what cell down? The textbox? Right click on it in the designer and hit properties and set Locked to true like Siddharth suggested. Also, if Environ doesn't work use VBA.Environ
To lock all the cells in the sheet just turn on protection. In the workbook_Open event do this
Private Sub Workbook_Open()
  Worksheets("Low Volume").Protect Password:="gary", UserInterfaceOnly:=True
End Sub

Open in new window

Then all the data will be protected from any changes except from within the code. Or you could protect the normal way (tools->protect sheet) and just unprotect and reprotect in the code.
0
 
LVL 37

Assisted Solution

by:TommySzalapski
TommySzalapski earned 668 total points
ID: 34227382
Here is a working example. Is this what you are after?
userform.xls
0
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 668 total points
ID: 34228461
I think this is what you need ?

Sid
Sample.xls
0
 
LVL 45

Expert Comment

by:patrickab
ID: 34228963
Tommy,

>I think he wants Environ("ComputerName")

As this would always be the same on any individual computer there would be little point in accessing it.

A password on the other hand would serve a purpose - probably.

Patrick
0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 34229901
Yeah, I realized that later. He said " It would just pick up the name of the PC" but then I saw the labels in the userform and decided he actually did want Username.
0
 
LVL 45

Expert Comment

by:patrickab
ID: 34230321
It's always a problem interpreting the question... perhaps the asker will clarify matters.

Patrick
0
 
LVL 45

Expert Comment

by:patrickab
ID: 34235195
Gazza83 - Thanks for the points - Patrick
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question