+ Reply to Thread
Results 1 to 3 of 3

Quirky, infrequent problem with code

  1. #1
    Don
    Guest

    Quirky, infrequent problem with code

    Hello again gang,

    Let's see if I can explain this quirk correctly.....I've posted all the code
    involved below.

    Here's what it's supposed to do:

    On UF2 there are 52 buttons, by clicking on any one of them you are taken to
    the "Data" sheet. Then that sheet is split and certain columns are hidden,
    depending upon the button selected on UF2. This allows the OP to see what he
    needs to see and enter data only in the cells that are unlocked. When the
    "Save Data" button on "Data" sheet is clicked all Cols are unhidden and the
    WB is saved and you are returned to UF2. This all works well, most of the
    time, however occassionally, after the button click on UF2, the program
    flashes and returns you to UF2. By clicking again on the button (sometimes
    it takes 3-4 clicks) the program will finally land on the "Data" sheet as
    it's supposed to. When this happens, no error msgs appear and it appears to
    do no harm to the WB, but it is very aggravating. It's also difficult to
    reproduce, as it only happens infrequently. Any help would be greatly
    appreciated in cornering this bug.

    The Layout:

    On "Data" sheet:
    Cols "A,B,C" are locked
    Rows "1,2" are locked
    All other cells are unlocked
    There is a Button ("Save Data") that resides over cells B2:C2

    The below Sub Jul05 is reached through a button click on a form UF2 that I
    developed.
    There are 52 Subs that Call SplitDataSheet and then hide various Cols.

    Sub Jul05()

    Call SplitDataSheet
    Columns("G:IV").Select
    Selection.EntireColumn.Hidden = True
    Range("D3").Select
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    ActiveSheet.EnableSelection = xlUnlockedCells

    End Sub

    Sub SplitDataSheet()

    Sheets("DATA").Select
    ActiveSheet.Unprotect
    Columns("A:IV").Select
    Selection.EntireColumn.Hidden = False
    Range("D3").Select
    ActiveWindow.FreezePanes = True

    End Sub

    The "Save Data" button has the following code:

    Sub SaveData()

    ActiveSheet.Unprotect
    Columns("A:IV").Select
    Selection.EntireColumn.Hidden = False
    ActiveWindow.FreezePanes = False
    Range("A1").Select
    MsgBox "Workbook Will Now Be Saved!"
    ActiveWorkbook.Save
    UF2.Show

    End Sub

    I hope that's enough info to find this bug.....appreciate any help here,

    Don

  2. #2
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    Don i'm no whizz at this but have you tried Set Focus to an item on your UF2? maybe this will help..............maybe not, just a thought!

    Regards,
    Simon

  3. #3
    Don
    Guest

    Re: Quirky, infrequent problem with code


    G'mornin Simon,

    Thanks for looking at this. I guess I did forget something and that is the
    button click command, but that's pretty straight forward...code is:

    Private Sub CommandButton1_Click()

    Unload UF2
    Call Jul05

    End Sub

    I'm too am certainly not a whiz at this....I frequent here often for help,
    either by postings or by searches through the archives.

    As I said, this problem only happens infrequently and yesterday after
    posting my question, I couldn't for the life of me get the program to
    misbehave.....lol

    I'll code the following into UF2's code and see what happens.

    Private Sub UserForm_Activate()

    CommandButton1.SetFocus

    End Sub

    Meanwhile, any other comments or suggestions would be appreciated,

    Thanks again,

    Don
    "Simon Lloyd" wrote:

    >
    > Don i'm no whizz at this but have you tried Set Focus to an item on your
    > UF2? maybe this will help..............maybe not, just a thought!
    >
    > Regards,
    > Simon
    >
    >
    > --
    > Simon Lloyd
    > ------------------------------------------------------------------------
    > Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
    > View this thread: http://www.excelforum.com/showthread...hreadid=571064
    >
    >


+ 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