Consulting

Results 1 to 17 of 17

Thread: Selecting Cells Advanced

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Quick one both,

    Unfortunately P45cal your

    Set originalactivecell = Activecell
    and

    OriginalActivecell.activate
    does not work

    Jdelanos code

      ' keep a list of the cells the user had selected so they can be reselected
            preSelectedCells = preSelectedCells & cel.Address & ","
        Next cel
        
        ' move the trailing coma
        preSelectedCells = Left(preSelectedCells, Len(preSelectedCells) - 1)
        
        ' reselect the previously selected cells
        ActiveSheet.range(preSelectedCells).Select
    Does work

    i am using check boxes on a userform to activate the cells if i unselect all checkboxes i would like it to go back to the original selection?

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,892
    Quote Originally Posted by Johnnydotcom View Post
    Unfortunately P45cal your
    Set originalactivecell = Activecell
    and
    OriginalActivecell.activate
    does not work
    Well, I tested it here before posting.
    Perhaps because
    Quote Originally Posted by Johnnydotcom View Post
    is manually selected by a user
    isn't accurate?

    Quote Originally Posted by Johnnydotcom View Post
    i am using check boxes on a userform to activate the cells
    Maybe attach a version of the workbook and userform. There are a number of reasons that part might not work.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    Hi P45cal, i cannot post the workbook for Data protection act reasons, The work flow is like this, the Cells are originally selected manually by a user, then the useform is started, the checkboxes are used to activate the macro

    I test all macros without userform first to prove the macro. what happens my end when testing like this is I manually select the cells as shown in my images, i run your code without the two extra codes and the function performs just as i asked, however, when i turn on the two extra codes, it separates the selection from a range to individual selections, not going back to the originally selected cells.

    below i show the images of the result when testing with out the userform.

    First test without comments

    Sub blah()
    'Set originalActiveCell = ActiveCell
    Set newSelection = ActiveCell
    For Each are In Selection.Areas
      Set newSelection = Union(newSelection, are, are.offset(1))
    Next are
    newSelection.Select
    'originalActiveCell.Activate
    End Sub
    result

    Activecell = top selection
    Top selection.jpg

    Sub blah()
    Set originalActiveCell = ActiveCell
    Set newSelection = ActiveCell
    For Each are In Selection.Areas
      Set newSelection = Union(newSelection, are, are.offset(1))
    Next are
    newSelection.Select
    originalActiveCell.Activate
    End Sub
    Activecell = Bottom selection
    Btm Selection.jpg

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •