CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2001
    Posts
    60

    VBA Excel question ???

    is it possible to affect a specific cell value to the name of its worksheet ?

    Make it with rocker style \w/

  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: VBA Excel question ???

    If you mean you want to affect a cell on a specific worksheet?

    ' myWorkbook is an object pointing to an excel workbook
    myWorkbook.Sheets("The name of my sheet").Range("A1").Value = "Some value"




    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  3. #3
    Join Date
    Aug 2001
    Posts
    60

    Re: VBA Excel question ???

    huumm
    I want to change the value of the sheet's name with the value of the cell.
    For example. my sheets "number1" contains 10 cells (A2, A3, A4, A5, A6,...)
    if I change the value of the cell "A2", then, it change the name of the sheets "number2" also..

    I want to link these 2 values.

    Make it with rocker style \w/

  4. #4
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: VBA Excel question ???

    Add this code to the worksheet the cells are on. It will check if one of the cells changes, and then rename the appropriate sheet

    private Sub Worksheet_Change(byval Target as Excel.Range)

    If Target.Column = 1 then
    Select Case Target.Row
    Case 2 to 10
    ThisWorkbook.Sheets(Target.Row).Name = Target.Value
    End Select
    End If

    End Sub




    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  5. #5
    Join Date
    Aug 2001
    Posts
    60

    Re: VBA Excel question ???

    yeah,
    that's exactly what I wanted to do.
    thanks, :O)

    Make it with rocker style \w/

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured