+ Reply to Thread
Results 1 to 2 of 2

Floating Command Button

Hybrid View

  1. #1
    Forum Contributor GuruWannaB's Avatar
    Join Date
    01-24-2008
    Location
    An hour due East of Cowtown Ohio
    MS-Off Ver
    2010
    Posts
    421

    Floating Command Button

    I have a command button that I don't actually use as a button...but as a floating body on the spreadsheet with instructions.

    By right clicking on the tab and selecting CODE...I have the following:

    Private Sub Worksheet_selectionChange(ByVal Target As Range)
        With ActiveWindow.VisibleRange
            Me.CommandButton2.Top = .Top
        End With
    Now this code works great. Everytime I scroll up or down the page and select a CELL to update...the button appears on the visible part of the page.

    What it is I need help with, is that this only works, or triggers, when I select a Cell to update. I have a spreadsheet with over 200 Yes / No questions where the user indicates their answer by selecting a Checkbox. I would like the trigger to also be when the user places a checkmark in a checkbox. Any suggestions on updating this code to INCLUDE this trigger as well?

    Thanks everyone - I love this forum...and try to contribute as much as I can...I'm just at the point of time where I need to make a withdrawal from genius pool!

    GWB
    Last edited by GuruWannaB; 04-07-2009 at 04:51 PM. Reason: Because I discovered the answer!! =)

  2. #2
    Forum Contributor GuruWannaB's Avatar
    Join Date
    01-24-2008
    Location
    An hour due East of Cowtown Ohio
    MS-Off Ver
    2010
    Posts
    421

    Re: Floating Command Button

    Well...I tried something and it worked! WAHOO!!

    What I did was ADDED the following - I did not delete any code...just added some additional.

    Private Sub Worksheet_Calculate()
        With ActiveWindow.VisibleRange
            Me.CommandButton2.Top = .Top
        End With
    End Sub
    The code in the first post moves the button when a selection change is made (CELL BASED SELECTION).

    This code will move the button when there is a calculation done...which i have every checkbox coded to uncheck the opposite YES or NO for the same question - meaning I have my calculation occurring every checkbox click. A little clunky...but hey, it WORKS!!

    Just thought I would post the solution....hope this helps someone else!

    GWB
    I help because of the Pavlovian dog that resides in the inner me...so if you are happy with the results, please add to my reputation. It helps keep me motivated!



    Please mark your threads as Solved once it is solved. Check the FAQ's to see how.

+ 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