+ Reply to Thread
Results 1 to 3 of 3

Using cell names (not addresses) for target.range

Hybrid View

  1. #1
    Registered User
    Join Date
    01-07-2010
    Location
    Boston, MA
    MS-Off Ver
    Excel 2007
    Posts
    25

    Using cell names (not addresses) for target.range

    Hi - I have a number of cells that have been named (ie cells I4 and J4 are also called "_BottomF" and "_TopF"). I have some code that looks like this:

    Private Sub Worksheet_Change(ByVal Target As Range)
        Application.EnableEvents = False
        If Target.Address = "$H$4" Or Target.Address = "$I$4" Then
            If Worksheets("Type3").Range("_BottomF") < Worksheets("Type3").Range("_TopF") Then
                'set new bounds
                ActiveSheet.ChartObjects("Type3BoostPhase").Chart.Axes(xlCategory).MinimumScale = Worksheets("Type3Boost").Range("_BottomF")
                ActiveSheet.ChartObjects("Type3BoostPhase").Chart.Axes(xlCategory).MaximumScale = Worksheets("Type3Boost").Range("_TopF")
            End If
        End If
        Application.EnableEvents = True
    End Sub
    I would like to replace the "$H$4" with "_BottomF", but I get an error message. What is the correct way of doing this?

    Thanks!

    edit: Title was supposed to be Using, not Ssing!
    Last edited by nleahcim; 09-24-2012 at 01:41 PM.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Using cell names (not addresses) for target.range

    Hi, nleahcim,

        If Target.Address = Range("_BottomF").Address Or Target.Address = Range("_TopF").Address Then
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    01-07-2010
    Location
    Boston, MA
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Using cell names (not addresses) for target.range

    Quote Originally Posted by HaHoBe View Post
    Hi, nleahcim,

        If Target.Address = Range("_BottomF").Address Or Target.Address = Range("_TopF").Address Then
    Ciao,
    Holger
    Hi Holger - that worked great! Thanks for your help!

+ 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