+ Reply to Thread
Results 1 to 7 of 7

On click question?

  1. #1
    Jeff
    Guest

    On click question?

    Is there a way to add an x in a when you click in a cell in a range like
    B3:G99 only and not the whole sheet? Right now I can do it to the whole sheet
    with
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    ActiveCell.Value = "x"
    End Sub
    Thanks!

  2. #2
    Tom Ogilvy
    Guest

    Re: On click question?


    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    if Target.count >1 then exit sub
    if not Intersect(target,Range("B3:G99") is nothing then
    Target.Value = "x"
    End if
    End Sub


    if you want to toggle the x

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    if Target.count >1 then exit sub
    if not Intersect(target,Range("B3:G99") is nothing then
    if isempty(Target.Value) then
    Target.Value = "x"
    else
    Target.clearContents
    End if
    End if
    End Sub

    --
    Regards,
    Tom Ogilvy

    "Jeff" <[email protected]> wrote in message
    news:[email protected]...
    > Is there a way to add an x in a when you click in a cell in a range like
    > B3:G99 only and not the whole sheet? Right now I can do it to the whole

    sheet
    > with
    > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > ActiveCell.Value = "x"
    > End Sub
    > Thanks!




  3. #3
    Jeff
    Guest

    Re: On click question?

    I get a syntax error on the intersect. Any idea why?

    "Tom Ogilvy" wrote:

    >
    > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > if Target.count >1 then exit sub
    > if not Intersect(target,Range("B3:G99") is nothing then
    > Target.Value = "x"
    > End if
    > End Sub
    >
    >
    > if you want to toggle the x
    >
    > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > if Target.count >1 then exit sub
    > if not Intersect(target,Range("B3:G99") is nothing then
    > if isempty(Target.Value) then
    > Target.Value = "x"
    > else
    > Target.clearContents
    > End if
    > End if
    > End Sub
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "Jeff" <[email protected]> wrote in message
    > news:[email protected]...
    > > Is there a way to add an x in a when you click in a cell in a range like
    > > B3:G99 only and not the whole sheet? Right now I can do it to the whole

    > sheet
    > > with
    > > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > > ActiveCell.Value = "x"
    > > End Sub
    > > Thanks!

    >
    >
    >


  4. #4
    Tom Ogilvy
    Guest

    Re: On click question?

    See fixed typo:

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    if Target.count >1 then exit sub
    if not Intersect(target,Range("B3:G99")) is nothing then
    Target.Value = "x"
    End if
    End Sub


    if you want to toggle the x

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    if Target.count >1 then exit sub
    if not Intersect(target,Range("B3:G99")) is nothing then
    if isempty(Target.Value) then
    Target.Value = "x"
    else
    Target.clearContents
    End if
    End if
    End Sub

    --
    Regards,
    Tom Ogilvy

    "Jeff" <[email protected]> wrote in message
    news:[email protected]...
    > I get a syntax error on the intersect. Any idea why?
    >
    > "Tom Ogilvy" wrote:
    >
    > >
    > > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > > if Target.count >1 then exit sub
    > > if not Intersect(target,Range("B3:G99") is nothing then
    > > Target.Value = "x"
    > > End if
    > > End Sub
    > >
    > >
    > > if you want to toggle the x
    > >
    > > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > > if Target.count >1 then exit sub
    > > if not Intersect(target,Range("B3:G99") is nothing then
    > > if isempty(Target.Value) then
    > > Target.Value = "x"
    > > else
    > > Target.clearContents
    > > End if
    > > End if
    > > End Sub
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > > "Jeff" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > Is there a way to add an x in a when you click in a cell in a range

    like
    > > > B3:G99 only and not the whole sheet? Right now I can do it to the

    whole
    > > sheet
    > > > with
    > > > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > > > ActiveCell.Value = "x"
    > > > End Sub
    > > > Thanks!

    > >
    > >
    > >




  5. #5
    Jeff
    Guest

    Re: On click question?

    I found it. Thank you for your help! Jeff

    "Tom Ogilvy" wrote:

    >
    > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > if Target.count >1 then exit sub
    > if not Intersect(target,Range("B3:G99") is nothing then
    > Target.Value = "x"
    > End if
    > End Sub
    >
    >
    > if you want to toggle the x
    >
    > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > if Target.count >1 then exit sub
    > if not Intersect(target,Range("B3:G99") is nothing then
    > if isempty(Target.Value) then
    > Target.Value = "x"
    > else
    > Target.clearContents
    > End if
    > End if
    > End Sub
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "Jeff" <[email protected]> wrote in message
    > news:[email protected]...
    > > Is there a way to add an x in a when you click in a cell in a range like
    > > B3:G99 only and not the whole sheet? Right now I can do it to the whole

    > sheet
    > > with
    > > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > > ActiveCell.Value = "x"
    > > End Sub
    > > Thanks!

    >
    >
    >


  6. #6
    -JEFF-
    Guest

    Re: On click question?

    Mr. Ogilvy,
    A different Jeff here. I have been unable to get this to work on a cell
    that has been merged. Would you please test that and see if that is the
    case? If so, is there a fix? Thanks! -JEFF-

    "Tom Ogilvy" wrote:

    > See fixed typo:
    >
    > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > if Target.count >1 then exit sub
    > if not Intersect(target,Range("B3:G99")) is nothing then
    > Target.Value = "x"
    > End if
    > End Sub
    >
    >
    > if you want to toggle the x
    >
    > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > if Target.count >1 then exit sub
    > if not Intersect(target,Range("B3:G99")) is nothing then
    > if isempty(Target.Value) then
    > Target.Value = "x"
    > else
    > Target.clearContents
    > End if
    > End if
    > End Sub
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "Jeff" <[email protected]> wrote in message
    > news:[email protected]...
    > > I get a syntax error on the intersect. Any idea why?
    > >
    > > "Tom Ogilvy" wrote:
    > >
    > > >
    > > > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > > > if Target.count >1 then exit sub
    > > > if not Intersect(target,Range("B3:G99") is nothing then
    > > > Target.Value = "x"
    > > > End if
    > > > End Sub
    > > >
    > > >
    > > > if you want to toggle the x
    > > >
    > > > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > > > if Target.count >1 then exit sub
    > > > if not Intersect(target,Range("B3:G99") is nothing then
    > > > if isempty(Target.Value) then
    > > > Target.Value = "x"
    > > > else
    > > > Target.clearContents
    > > > End if
    > > > End if
    > > > End Sub
    > > >
    > > > --
    > > > Regards,
    > > > Tom Ogilvy
    > > >
    > > > "Jeff" <[email protected]> wrote in message
    > > > news:[email protected]...
    > > > > Is there a way to add an x in a when you click in a cell in a range

    > like
    > > > > B3:G99 only and not the whole sheet? Right now I can do it to the

    > whole
    > > > sheet
    > > > > with
    > > > > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > > > > ActiveCell.Value = "x"
    > > > > End Sub
    > > > > Thanks!
    > > >
    > > >
    > > >

    >
    >
    >


  7. #7
    Tom Ogilvy
    Guest

    Re: On click question?

    In general,

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Count > 1 And Not Target.MergeCells Then Exit Sub
    If Not Intersect(Target, Range("B3:G99")) Is Nothing Then
    Target(1).Value = "x"
    End If
    End Sub

    --
    Regards,
    Tom Ogilvy

    "-JEFF-" <[email protected]> wrote in message
    news:[email protected]...
    > Mr. Ogilvy,
    > A different Jeff here. I have been unable to get this to work on a cell
    > that has been merged. Would you please test that and see if that is the
    > case? If so, is there a fix? Thanks! -JEFF-
    >
    > "Tom Ogilvy" wrote:
    >
    > > See fixed typo:
    > >
    > > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > > if Target.count >1 then exit sub
    > > if not Intersect(target,Range("B3:G99")) is nothing then
    > > Target.Value = "x"
    > > End if
    > > End Sub
    > >
    > >
    > > if you want to toggle the x
    > >
    > > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > > if Target.count >1 then exit sub
    > > if not Intersect(target,Range("B3:G99")) is nothing then
    > > if isempty(Target.Value) then
    > > Target.Value = "x"
    > > else
    > > Target.clearContents
    > > End if
    > > End if
    > > End Sub
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > > "Jeff" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > I get a syntax error on the intersect. Any idea why?
    > > >
    > > > "Tom Ogilvy" wrote:
    > > >
    > > > >
    > > > > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > > > > if Target.count >1 then exit sub
    > > > > if not Intersect(target,Range("B3:G99") is nothing then
    > > > > Target.Value = "x"
    > > > > End if
    > > > > End Sub
    > > > >
    > > > >
    > > > > if you want to toggle the x
    > > > >
    > > > > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > > > > if Target.count >1 then exit sub
    > > > > if not Intersect(target,Range("B3:G99") is nothing then
    > > > > if isempty(Target.Value) then
    > > > > Target.Value = "x"
    > > > > else
    > > > > Target.clearContents
    > > > > End if
    > > > > End if
    > > > > End Sub
    > > > >
    > > > > --
    > > > > Regards,
    > > > > Tom Ogilvy
    > > > >
    > > > > "Jeff" <[email protected]> wrote in message
    > > > > news:[email protected]...
    > > > > > Is there a way to add an x in a when you click in a cell in a

    range
    > > like
    > > > > > B3:G99 only and not the whole sheet? Right now I can do it to the

    > > whole
    > > > > sheet
    > > > > > with
    > > > > > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > > > > > ActiveCell.Value = "x"
    > > > > > End Sub
    > > > > > Thanks!
    > > > >
    > > > >
    > > > >

    > >
    > >
    > >




+ 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