+ Reply to Thread
Results 1 to 6 of 6

Worksheet activate place text in cell.

Hybrid View

Lensmeister Worksheet activate place text... 10-05-2012, 04:19 PM
Lensmeister Re: Worksheet activate place... 10-05-2012, 04:39 PM
roki4 Re: Worksheet activate place... 10-05-2012, 04:52 PM
Lensmeister Re: Worksheet activate place... 10-05-2012, 04:47 PM
ChemistB Re: Worksheet activate place... 10-05-2012, 04:57 PM
Lensmeister Re: Worksheet activate place... 10-06-2012, 11:52 AM
  1. #1
    Forum Contributor
    Join Date
    12-05-2006
    Location
    London
    MS-Off Ver
    Excel 365 (Version 2008) [work] & 365 [home]
    Posts
    189

    Question Worksheet activate place text in cell.

    Hi all,

    Think I'm being dumber than normal.

    I have a workbook.

    When a worksheet (intro) is selected I need the cell B28 to read "No of players that have played for TEAM"

    Now the TEAM can be any team, but it is named properly on a sheet called setup in cell D1 and the cell is named MyTeam.

    I think that the code should read

    Private Sub Worksheet_Activate()
        XXXXX "No of players who have played for" & MyTeam & " ."
        
        
    End Sub
    I can't fathom out what the XXXXX code needs to be to complete this.

    Please can someone help me?

    Thanks.
    Last edited by Lensmeister; 10-05-2012 at 04:48 PM. Reason: Solved
    A mad football researcher and Statistician - ok just mad really !

  2. #2
    Forum Contributor
    Join Date
    12-05-2006
    Location
    London
    MS-Off Ver
    Excel 365 (Version 2008) [work] & 365 [home]
    Posts
    189

    Re: Worksheet activate place text in cell.

    I have managed to get this far

    Private Sub Worksheet_Activate()
    
    Range("B28").Value = "No. of players who have played for" + myteam + "."
     
    End Sub
    I have tried both & and + but cannot get it work

  3. #3
    Forum Contributor
    Join Date
    02-15-2012
    Location
    Vancouver, BC
    MS-Off Ver
    Excel 2003
    Posts
    125

    Re: Worksheet activate place text in cell.

    Give this a try:


    Private Sub Workbook_SheetActivate(ByVal Sh As Object)
    Dim CellValue As String
    
        CellValue = Worksheets("intro").Range("$B$28").Value
    
    MsgBox "No of players that have played for " & CellValue & "."
    
    End Sub
    B.Econ, CFA

  4. #4
    Forum Contributor
    Join Date
    12-05-2006
    Location
    London
    MS-Off Ver
    Excel 365 (Version 2008) [work] & 365 [home]
    Posts
    189

    Re: Worksheet activate place text in cell.

    SOLVED:

    Private Sub Worksheet_Activate()
    Dim MyTeam As String
        MyTeam = Worksheets("set_up").Range("D1").Value
            Range("B28").Value = "No. of players who have played for " + MyTeam + "."
     
    End Sub

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Worksheet activate place text in cell.

    If the cell in sheet Setup is named myteam, you can simply use
    Range("B28") = "No. of players who have played for " & Sheets("Setup").Range("myteam")&"."
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  6. #6
    Forum Contributor
    Join Date
    12-05-2006
    Location
    London
    MS-Off Ver
    Excel 365 (Version 2008) [work] & 365 [home]
    Posts
    189

    Re: Worksheet activate place text in cell.

    Thanks ... I'll give this a spin too.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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