ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inserting Environment Variables into Cells (https://www.excelbanter.com/excel-programming/373766-inserting-environment-variables-into-cells.html)

Tevibear

Inserting Environment Variables into Cells
 
Hi,

I can't seem to figure out the simple code to put environment variables
into the cells of my choice with the click of a command button.

This is about as far as I got:

Private Sub Inert_Variables_Click()
ActiveCell = Environ("windir")
End Sub

I don't really want to use the activeCell object if I don't have to. Is
there a simple way like telling it which individual cells I want to
insert the different variables into like:

Cell A3 = Environ("windir")
Cell B7 = Environ("winbootdir")
Cell D4 = Environ("userprofile")
etc...

I really don't know where else to ask for help on this. There has got to
be a really simple way to do this.

Please help.

Thanks,

Kevin Hunter
Fabrication Specialist

Helmut Weber[_2_]

Inserting Environment Variables into Cells
 
Hi Tevibear,

like this:

Sub test()
' cells(row, column)
ActiveSheet.Cells(1, 1).Value = Environ("Username")
End Sub

--

Helmut Weber

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Tevibear

Inserting Environment Variables into Cells
 
Thank you so much!!! You are the bomb! :)


Helmut Weber wrote:

Hi Tevibear,

like this:

Sub test()
' cells(row, column)
ActiveSheet.Cells(1, 1).Value = Environ("Username")
End Sub

--

Helmut Weber

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"



All times are GMT +1. The time now is 02:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com