formula correct - display is funny

  • Thread starter RebekahK20_pontiac via OfficeKB.com
  • Start date
R

RebekahK20_pontiac via OfficeKB.com

OK I've got a spreadsheet that reads the windows User Name and displays it
properly in the cell I choose. However when this is used to load data into
another program it grabs the cells content which is actually =UserNameWindows
()...
I need the other program to read the cell as the result of that formula.

This is how I get to the =UserNameWindows() result - any suggestions on how
to change the display? would be greatly appreciated...




Function UserNameWindows() As String
UserNameWindows = Environ("USERNAME")
End Function


Sub AutoFillIn()
Dim myNames As Variant
Dim c As Range
Dim res As Variant

myNames = Array("dadunlap", "slhull", "mdringler", _
"sljackson", "ccparker", "thenry", _
"rdowling", "jslong", "mhjames", _
"lndavis", "jdscott", "jfullem", _
"alwrinch")

For Each c In Range("A8:A1000")
If c.Value = "" Then
Exit For
End If
c.Offset(0, 8).Formula = "=UserNameWindows()"
res = Application.Match(UserNameWindows, myNames, 0)
If IsNumeric(res) Then
'found it
c.Offset(0, 6).Value = "YES"
Else
c.Offset(0, 6).Value = "NO"
End If
Next c
End Sub


TIA
Rebekah
 
M

Michael

Change the c.Offset(0, 8).Formula = "=UserNameWindows()"
to: c.Offset(0,8).value = UserNameWindows
 
A

Arnie

This seems to work for me:

Function UserNameWindows() As String
UserNameWindows = Environ("USERNAME")
End Function


Sub AutoFillIn()
Dim myNames As Variant
Dim c As Range
Dim res As Variant

myNames = Array("dadunlap", "slhull", "mdringler", _
"sljackson", "ccparker", "thenry", _
"rdowling", "jslong", "mhjames", _
"lndavis", "jdscott", "jfullem", _
"alwrinch")

For Each c In Range("A8:A1000")
If c.Value = "" Then
Exit For
End If
c.Offset(0, 8).Formula = "=UserNameWindows()"
res = Application.Match(UserNameWindows, myNames, 0)
If IsNumeric(res) Then
'found it
c.Offset(0, 6).Value = "YES"
Else
c.Offset(0, 6).Value = "NO"
End If
Range("I8:I1000").Select
Selection.Copy
Range("I8").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A8").Select
Next c
End Sub
 
R

RebekahK20_pontiac via OfficeKB.com

Thanks it worked perfectly... so simple too...

Rebekah
Change the c.Offset(0, 8).Formula = "=UserNameWindows()"
to: c.Offset(0,8).value = UserNameWindows
OK I've got a spreadsheet that reads the windows User Name and displays it
properly in the cell I choose. However when this is used to load data into
[quoted text clipped - 38 lines]
TIA
Rebekah
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top