+ Reply to Thread
Results 1 to 14 of 14

POP Up when select columns

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-21-2007
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    389

    POP Up when select columns

    Hello Guys,

    I need to have a pop-up appearing each time a user attend to "Edit"/"select" the below columns:
    D:D
    F:H
    J:J
    N:N

    Pop-up could mention: "That cells should not be used"..

    Is it possible?

    many thanks,
    Graig

    PS: If this is possible, I would be interested to know whether you can apply that to a inserted table...

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: POP Up when select columns

    Hi, Craig,

    you could lock the cells.

    Maybe use the Woeksheet_SelelcitonChange-event (right click on the worksheet tab, choose View Code, paste the code into the code window):

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Select Case Target.Column
      Case 4, 6 To 8, 10, 14
        MsgBox "That cells should not be used"
        Target.Offset(0, 1).Select
      Case Else
    End Select
    End Sub
    Code worked in one of my tables just the same.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Contributor
    Join Date
    02-21-2007
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    389

    Re: POP Up when select columns

    Whaouu ! Perfect, 2 questions though:

    1) I already had a macro in the worksheet tab. how do you combine your macro with mine:
    HTML Code: 
    2) you said that I could lock the cells. how do you do that? I mean when I lock partialy my file, and try to edit a cell which is not locked, I simply cannot. When I let the user modify the unlocked cells then the locked ones (where I have my formulas) are not protected anymore.

    Many thanks Holger!
    Graig

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: POP Up when select columns

    Hi, graiggoriz,

    Workbook_Open belongs into ThisWorkbook as the event will not be fired anywhere else.

    Depending on what you want the user to do. As default all cells are locked so once you apply any protection for a sheet all cells will get locked not letting any changes to be made. You would need to unlock those cells you wan the user to enter data and then apply the protection.

    Ciao,
    Holger

  5. #5
    Forum Contributor
    Join Date
    02-21-2007
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    389

    Re: POP Up when select columns

    Thanks Holger.

    Anyway to adapt your macro to a Table??

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: POP Up when select columns

    Hi, Graig ,

    I tested the code with one of my tables (starting at A1) and it worked there. You would need to explain what you want the macro to do, how the table is named and where in the sheet it starts, what action to be taken when... Maybe attach a sample workbook and explain in there.

    What I might guess from here: instead of having the column numbers you could compare the first row of the table to headings and skip those you donīt want data to be entered.

    Ciao,
    Holger

  7. #7
    Forum Contributor
    Join Date
    02-21-2007
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    389

    Re: POP Up when select columns

    Hello Holger,

    The table name is "Table1" (range: $B$26:$O$71). As you mentionned I have attached an excel file sample.

    My idea is to protect the worksheet but unprotect my table as I would need to edit format cells. However the cells colored in bleu in that table should not be editable (especialy the formulas).

    If you need further info, please let me know.

    Many thanks,
    Graig
    Attached Files Attached Files

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: POP Up when select columns

    Hi, Graig,

    maybe just lock the cells you donīt wan tto be entered and apply Protection like
    Sub EF965258()
      With ActiveSheet
        .Protect DrawingObjects:=True, _
            Contents:=True, _
            Scenarios:=True, _
            AllowFormattingCells:=True
        .EnableSelection = xlUnlockedCells
      End With
    End Sub
    Regarding the Worksheet_SelectionChange-event I just come up with soemthing like
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Not Intersect(Target, Range("Table1")) Is Nothing Then
      Select Case Target.Column
        Case 4, 6 To 8, 10, 14
          MsgBox "Cells from this column should not be used"
          Target.Offset(0, 1).Select
        Case Else
      End Select
    End If
    End Sub
    Code for this is disabled in the attached workbook.

    Ciao,
    Holger
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    02-21-2007
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    389

    Re: POP Up when select columns

    I've been already amazed twice by your work!! And you answer 2 thread for me :-D!!!

    Many thanks Holger. It is as usual perfect

  10. #10
    Forum Contributor
    Join Date
    02-21-2007
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    389

    Re: POP Up when select columns

    Hello Holger,

    Thanks to you I am using the following macro:

    HTML Code: 
    The last question I have in mind and really wonder if that would be possible:

    If I go from the left to the right on the defined columns, I jump them to the right. Therefore I have no way to go back to the left with the arrow keys, except if I use the mouse.

    Is there anyway to let the macro detect that I moved from right to left and let me jump the column to the left???

    Thanks again for your help.
    Graig

  11. #11
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: POP Up when select columns

    Hi, Graig,

    maybe like this (based on the workbook you posted):
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Not Intersect(Target, Range("Table1")) Is Nothing Then
      Select Case Target.Column
        Case 4, 6 To 8, 10, 14
          MsgBox "Cells from this column should not be used"
          Target.Offset(0, 1).Select
        Case Else
      End Select
    End If
    If Target.Column = 16 Then Cells(Target.Row + 1, 2).Select
    
    End Sub
    Ciao,
    Holger

  12. #12
    Forum Contributor
    Join Date
    02-21-2007
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    389

    Re: POP Up when select columns

    I actually thought about that solution too :-D I'm glad you thought the same way.

    But (Sorry to insist) is there any way when you are in "Case 5" to go back to Case 3?? (as per the attached file). I was just wondering whether the macro can be cleaver enought to detect that moving to the left (From case 5 to case 4) should let me go to the Case 3.

    I just want to know if using left arrow keys before going to column 16 is possible and how can that be done?

    Many Thanks
    Graig

  13. #13
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: POP Up when select columns

    Hi, Graig,

    this thread is still marked as Solved (and this can only be doen by the TO or anybody of the Staff) - maybe chage the status of the trhead if there are more questions to answer.

    The last workbook attached is from me while in your workbook there isnīt any VBA code - what workbook and idea are you talking about?
    But (Sorry to insist) is there any way when you are in "Case 5" to go back to Case 3??
    Add another Case for Column being 5 and put the cell where you think it should go (eitehr same row or one row below)?

    I just want to know if using left arrow keys before going to column 16 is possible and how can that be done?
    Work with the Worksheet_Change-event instead of Worksheet_SelectionChange-event and use Application.Undo to undo any change in the given columns (use ApplicationEnableEvents to switch events of prior to Undo and on after). You would need to mark the areas as done by now to inform the user that no changes may be made in these coloured areas.

    No problem should occur when working with a protected sheet where only unprotected sheets may be selected/changed.

    Ciao,
    Holger
    Last edited by HaHoBe; 11-06-2013 at 05:22 PM.

  14. #14
    Forum Contributor
    Join Date
    02-21-2007
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    389

    Re: POP Up when select columns

    Correct Holger! I created a new Thread. Many Thanks for our help

    http://www.excelforum.com/excel-prog...ml#post3470477

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Multi Select ListBox, 4 columns, use NamedRange, Columns to use in list Nonconsecutive
    By CRIMEDOG in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-29-2013, 11:01 AM
  2. [SOLVED] Unable to select columns with columns.("D:D").select
    By KAPearson in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-23-2012, 09:16 AM
  3. Code to prevent user to Select COLUMNS but allow to select ROWS
    By tengrosita in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-05-2011, 03:46 AM
  4. Select Columns in a set row
    By coreytroy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-02-2010, 01:50 AM
  5. Select columns and add the content of the columns to a mail
    By bananas in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-08-2007, 02:31 PM

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