Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default writing to next row in sheet

here is the unworking script:

Private Sub Workbook_open()
Worksheets("Frontscreen").Activate
ActiveSheet.Unprotect

Dim x
Set x = CreateObject("WSCRIPT.Network")
Dim u
u = x.UserName
t = Time
'update text box "Last Updated:"
ActiveSheet.TextBoxes("txtLogon").Text = "Welcome to IRIS " & u & " -
Access Time: " & t
ActiveSheet.Protect


lastrow = Worksheets("log").Cells(Rows.Count, "A").End(xlUp).Row
Loglisting = txtLogon.Value

Worksheets("Log").Range("A" & lastrow + 1).Value = Loglisting

End Sub
Basically when workbook opens the current user is identified and displayed
using text box. I want this value to be copied to the next available line
in a log worksheet that is hidden from the user.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default writing to next row in sheet

Which bit is not working? There is a simpler way to get the user

Private Sub Workbook_open()
Worksheets("Frontscreen").Activate
ActiveSheet.Unprotect

Dim u
u = Environ("Username")
t = Time
'update text box "Last Updated:"
ActiveSheet.TextBoxes("txtLogon").Text = "Welcome to IRIS " & _
u & " - Access Time: " & t
ActiveSheet.Protect

lastrow = Worksheets("log").Cells(Rows.Count, "A").End(xlUp).Row
Loglisting = txtLogon.Value

Worksheets("Log").Range("A" & lastrow + 1).Value = Loglisting

End Sub



--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"sacrum" wrote in message
...
here is the unworking script:

Private Sub Workbook_open()
Worksheets("Frontscreen").Activate
ActiveSheet.Unprotect

Dim x
Set x = CreateObject("WSCRIPT.Network")
Dim u
u = x.UserName
t = Time
'update text box "Last Updated:"
ActiveSheet.TextBoxes("txtLogon").Text = "Welcome to IRIS " & u & " -
Access Time: " & t
ActiveSheet.Protect


lastrow = Worksheets("log").Cells(Rows.Count, "A").End(xlUp).Row
Loglisting = txtLogon.Value

Worksheets("Log").Range("A" & lastrow + 1).Value = Loglisting

End Sub
Basically when workbook opens the current user is identified and

displayed
using text box. I want this value to be copied to the next available line
in a log worksheet that is hidden from the user.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default writing to next row in sheet




lastrow = Worksheets("log").Cells(Rows.Count, "A").End(xlUp).Row
Loglisting = txtLogon.Value

Worksheets("Log").Range("A" & lastrow + 1).Value = Loglisting

End Sub


Its this last bit that causes a run time error - I have created a log
worksheet and the code above is located in ThisWorkbook visible in vb
editor.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default writing to next row in sheet

Hi,

I suggest you use

If IsEmpty(Range("A2")) Then
Sheets("Log").Range("A2").Value = Loglisting
Else
Sheets("Log").Range("A1").End(xlDown).Offset(1, 0).Value =
Loglisting
End If

for the last bit
Where I am presumming that you have a header in cell A1 on sheet Log

Hoop this helps,

Executor

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default writing to next row in sheet

What are all the variable values at that point, lastrow, Loglisting, etc.?

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"sacrum" wrote in message
...



lastrow = Worksheets("log").Cells(Rows.Count, "A").End(xlUp).Row
Loglisting = txtLogon.Value

Worksheets("Log").Range("A" & lastrow + 1).Value = Loglisting

End Sub


Its this last bit that causes a run time error - I have created a log
worksheet and the code above is located in ThisWorkbook visible in vb
editor.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default writing to next row in sheet

And you have more responses at your thread in .misc.

sacrum wrote:

here is the unworking script:

Private Sub Workbook_open()
Worksheets("Frontscreen").Activate
ActiveSheet.Unprotect

Dim x
Set x = CreateObject("WSCRIPT.Network")
Dim u
u = x.UserName
t = Time
'update text box "Last Updated:"
ActiveSheet.TextBoxes("txtLogon").Text = "Welcome to IRIS " & u & " -
Access Time: " & t
ActiveSheet.Protect

lastrow = Worksheets("log").Cells(Rows.Count, "A").End(xlUp).Row
Loglisting = txtLogon.Value

Worksheets("Log").Range("A" & lastrow + 1).Value = Loglisting

End Sub
Basically when workbook opens the current user is identified and displayed
using text box. I want this value to be copied to the next available line
in a log worksheet that is hidden from the user.


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default writing to next row in sheet


"Bob Phillips" wrote in message
...
What are all the variable values at that point, lastrow, Loglisting, etc.?

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"sacrum" wrote in message
...



lastrow = Worksheets("log").Cells(Rows.Count, "A").End(xlUp).Row
Loglisting = txtLogon.Value

Worksheets("Log").Range("A" & lastrow + 1).Value = Loglisting

End Sub


Its this last bit that causes a run time error - I have created a log
worksheet and the code above is located in ThisWorkbook visible in vb
editor.




vb runs through (below) but nothing happens in the log sheet - do I need to
do anything in the log sheet....?
Private Sub Workbook_open()
Worksheets("Frontscreen").Activate
ActiveSheet.Unprotect

Dim u
u = Environ("Username")
t = Time
'update text box "Last Updated:"
ActiveSheet.TextBoxes("txtLogon").Text = "Welcome to IRIS " & u & " -
Access Time: " & t
ActiveSheet.Protect

Dim Loglisting


If IsEmpty(Range("A2")) Then
Sheets("Log").Range("A2").Value = Loglisting
Else
Sheets("Log").Range("A1").End(xlDown).Offset(1, 0).Value =
Loglisting
End If

End Sub


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default writing to next row in sheet

which answers none of the questions I asked!

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"sacrum" wrote in message
...

"Bob Phillips" wrote in message
...
What are all the variable values at that point, lastrow, Loglisting,

etc.?

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"sacrum" wrote in message
...



lastrow = Worksheets("log").Cells(Rows.Count, "A").End(xlUp).Row
Loglisting = txtLogon.Value

Worksheets("Log").Range("A" & lastrow + 1).Value = Loglisting

End Sub


Its this last bit that causes a run time error - I have created a log
worksheet and the code above is located in ThisWorkbook visible in vb
editor.




vb runs through (below) but nothing happens in the log sheet - do I need

to
do anything in the log sheet....?
Private Sub Workbook_open()
Worksheets("Frontscreen").Activate
ActiveSheet.Unprotect

Dim u
u = Environ("Username")
t = Time
'update text box "Last Updated:"
ActiveSheet.TextBoxes("txtLogon").Text = "Welcome to IRIS " & u & " -
Access Time: " & t
ActiveSheet.Protect

Dim Loglisting


If IsEmpty(Range("A2")) Then
Sheets("Log").Range("A2").Value = Loglisting
Else
Sheets("Log").Range("A1").End(xlDown).Offset(1, 0).Value =
Loglisting
End If

End Sub




  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default writing to next row in sheet


sorry bob....

this works:

Option Explicit
Private Sub Workbook_open()
Dim x As Object
Dim u As String
Dim t As Date
Dim LastRow As Long

Set x = CreateObject("WSCRIPT.Network")

With Worksheets("FrontScreen")
.Activate
.Unprotect
u = x.UserName
t = Now
'update text box "Last Updated:"
.TextBoxes("txtLogon").Text _
= "Welcome to IRIS " & u & " - Access Time: " _
& Format(t, "hh:mm:ss")
.Protect
End With

With Worksheets("Log")
LastRow = Worksheets("log").Cells(.Rows.Count, "A").End(xlUp).Row
With .Cells(LastRow + 1, "A")
.Value = u
With .Offset(0, 1)
.Value = t
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
End With
End With
End With

End Sub

**thanks Dave


  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default writing to next row in sheet

Sometimes, it gets to be a pain--for both you and the responders--when you post
multiple messages to various newsgroups.

If you really think you have to post to several newsgroups (usually
unnecessary), you can cross post to all at once--just send one message, but send
it to all the newsgroups you want.

It helps you when you're searching for answers and it stops others from
responding to an already answered question.

And it also helps you by having others correct/enhance other suggestions.



sacrum wrote:

sorry bob....

this works:

Option Explicit
Private Sub Workbook_open()
Dim x As Object
Dim u As String
Dim t As Date
Dim LastRow As Long

Set x = CreateObject("WSCRIPT.Network")

With Worksheets("FrontScreen")
.Activate
.Unprotect
u = x.UserName
t = Now
'update text box "Last Updated:"
.TextBoxes("txtLogon").Text _
= "Welcome to IRIS " & u & " - Access Time: " _
& Format(t, "hh:mm:ss")
.Protect
End With

With Worksheets("Log")
LastRow = Worksheets("log").Cells(.Rows.Count, "A").End(xlUp).Row
With .Cells(LastRow + 1, "A")
.Value = u
With .Offset(0, 1)
.Value = t
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
End With
End With
End With

End Sub

**thanks Dave


--

Dave Peterson


  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default writing to next row in sheet


"Dave Peterson" wrote in message
...
Sometimes, it gets to be a pain--for both you and the responders--when you
post
multiple messages to various newsgroups.

If you really think you have to post to several newsgroups (usually
unnecessary), you can cross post to all at once--just send one message,
but send
it to all the newsgroups you want.

It helps you when you're searching for answers and it stops others from
responding to an already answered question.

And it also helps you by having others correct/enhance other suggestions.



sacrum wrote:

sorry bob....

this works:

Option Explicit
Private Sub Workbook_open()
Dim x As Object
Dim u As String
Dim t As Date
Dim LastRow As Long

Set x = CreateObject("WSCRIPT.Network")

With Worksheets("FrontScreen")
.Activate
.Unprotect
u = x.UserName
t = Now
'update text box "Last Updated:"
.TextBoxes("txtLogon").Text _
= "Welcome to IRIS " & u & " - Access Time: " _
& Format(t, "hh:mm:ss")
.Protect
End With

With Worksheets("Log")
LastRow = Worksheets("log").Cells(.Rows.Count, "A").End(xlUp).Row
With .Cells(LastRow + 1, "A")
.Value = u
With .Offset(0, 1)
.Value = t
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
End With
End With
End With

End Sub

**thanks Dave


--

Dave Peterson


hands up it was a mistake Dave.....to busy rushing around.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Allow only writing in a protected Sheet Piruzzi Setting up and Configuration of Excel 1 January 5th 09 11:59 PM
Writing formulas between sheet Dave Excel Discussion (Misc queries) 4 February 22nd 07 05:50 PM
Writing value in cell in another sheet John H W[_2_] Excel Programming 4 November 18th 04 07:10 PM
Writing to protected sheet from ASP.NET Winshent Excel Programming 3 November 5th 04 10:51 AM
Writing to protected sheet from ASP.NET Winshent Excel Programming 0 November 3rd 04 12:30 PM


All times are GMT +1. The time now is 09:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"