+ Reply to Thread
Results 1 to 3 of 3

In macros, an instruction that returns the position of the Active Cell

  1. #1
    aca
    Guest

    In macros, an instruction that returns the position of the Active Cell


    In a macro, how can I make it return the position of the Active Cell -
    Colum & Line.
    Or how can I set that position as a Condition; e.g. “If ActiveCell is
    B7 Then….”
    Or “If ActiveCell belongs to Column G Then….”
    Thanks in advance for any help.
    ACA


    --
    aca
    ------------------------------------------------------------------------
    aca's Profile: http://www.msusenet.com/member.php?userid=3856
    View this thread: http://www.msusenet.com/t-1873686451


  2. #2
    Roger Govier
    Guest

    Re: In macros, an instruction that returns the position of the Active Cell

    Hi

    Sub test()
    Dim ws1 As Worksheet
    Set ws1 = Workbooks("Tester.xls").Sheets("Sheet2")
    With ws1
    MsgBox ("Cell address is " & ActiveCell.Address)
    If Not Intersect(ActiveCell, .Range("J12:J20")) Is Nothing Then
    MsgBox ("Cell is in range J12:J20")
    End If
    If ActiveCell.Address = ("J17") Then
    MsgBox ("Do something")
    Else: MsgBox ("Do something else")
    End If
    End With
    End Sub


    --
    Regards

    Roger Govier


    "aca" <[email protected]> wrote in message
    news:[email protected]...
    >
    > In a macro, how can I make it return the position of the Active Cell -
    > Colum & Line.
    > Or how can I set that position as a Condition; e.g. "If ActiveCell is
    > B7 Then.."
    > Or "If ActiveCell belongs to Column G Then.."
    > Thanks in advance for any help.
    > ACA
    >
    >
    > --
    > aca
    > ------------------------------------------------------------------------
    > aca's Profile: http://www.msusenet.com/member.php?userid=3856
    > View this thread: http://www.msusenet.com/t-1873686451
    >




  3. #3
    Dave Peterson
    Guest

    Re: In macros, an instruction that returns the position of the ActiveCell

    I think in most cases:

    Set ws1 = Workbooks("Tester.xls").Sheets("Sheet2")
    should be replaced with:
    Set ws1 = ActiveSheet

    And watch out for:

    If ActiveCell.Address = "J17"

    The .address Returns dollar signs: $J$17 (and in uppercase, too).


    Roger Govier wrote:
    >
    > Hi
    >
    > Sub test()
    > Dim ws1 As Worksheet
    > Set ws1 = Workbooks("Tester.xls").Sheets("Sheet2")
    > With ws1
    > MsgBox ("Cell address is " & ActiveCell.Address)
    > If Not Intersect(ActiveCell, .Range("J12:J20")) Is Nothing Then
    > MsgBox ("Cell is in range J12:J20")
    > End If
    > If ActiveCell.Address = ("J17") Then
    > MsgBox ("Do something")
    > Else: MsgBox ("Do something else")
    > End If
    > End With
    > End Sub
    >
    > --
    > Regards
    >
    > Roger Govier
    >
    > "aca" <[email protected]> wrote in message
    > news:[email protected]...
    > >
    > > In a macro, how can I make it return the position of the Active Cell -
    > > Colum & Line.
    > > Or how can I set that position as a Condition; e.g. "If ActiveCell is
    > > B7 Then.."
    > > Or "If ActiveCell belongs to Column G Then.."
    > > Thanks in advance for any help.
    > > ACA
    > >
    > >
    > > --
    > > aca
    > > ------------------------------------------------------------------------
    > > aca's Profile: http://www.msusenet.com/member.php?userid=3856
    > > View this thread: http://www.msusenet.com/t-1873686451
    > >


    --

    Dave Peterson

+ 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