+ Reply to Thread
Results 1 to 8 of 8

Insert environ in cell when workbook activated

  1. #1
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    639

    Insert environ in cell when workbook activated

    Tried the below code to insert the environ username in W1 of Sheet1 when the workbook is opened but it's not working and I can't work out why.

    Anyone got any ideas why it'snot working?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: Insert environ in cell when workbook activated

    Is it working..

    Please Login or Register  to view this content.
    don't forget to save and re-open.. with "Enable Macro"

    EDIT: In your code... its looks fine for me.
    try to select a different sheet.. and come back to the 1st sheet.. hope will work..
    Regards!
    =DEC2HEX(3563)

    If you like someone's answer, click the star to give them a reputation point for that answer...

  3. #3
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    639

    Re: Insert environ in cell when workbook activated

    I've saved, closed and re-opened and it hasn't worked. Not sure what you've posted

    See attached book
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    639

    Re: Insert environ in cell when workbook activated

    Yes you're right.

    I deleted the (ByVal target As Range) and it works when you change sheets and return.

    I need this to work when the book is opened not when activated as there will only be one sheet when this is finished

  5. #5
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: Insert environ in cell when workbook activated

    Quote Originally Posted by Sc0tt1e View Post
    Private Sub Worksheet_Activate(ByVal target As Range)
    Did you write this parameter manually or someone suggested you.. !!!
    remove this RED code..

    EDIT: already guessed..

  6. #6
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    639

    Re: Insert environ in cell when workbook activated

    Still not working when I open it, tried changing to Sub Workbook_Open () but that isn't working either.

    Not sure how this should be done from open rather than when sheet activated

  7. #7
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    639

    Re: Insert environ in cell when workbook activated

    I had it in the wrong module, I had the code in Sheet1 instead of ThisWorkbook

    FYI, working code if anyone is interested.

    Please Login or Register  to view this content.

  8. #8
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: Insert environ in cell when workbook activated

    Thanks for feedback.. and updated code..

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Excel userf form should be visible only when that particular workbook is activated
    By sujithy007 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-09-2014, 11:52 PM
  2. Using the Environ Function on Workbook Open
    By hensucker in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-11-2012, 09:03 AM
  3. Copy from an non-activated workbook and paste into the active one
    By Ilias1987 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-05-2012, 05:58 PM
  4. VBA : Workbook which is open Already is not getting activated
    By Gurushankar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-08-2011, 01:30 PM
  5. Including Environ Username in Cell
    By swieduwi in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 03-30-2006, 11:43 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1