Consulting

Results 1 to 3 of 3

Thread: vba cell event change & call macro combination

  1. #1
    VBAX Regular
    Joined
    Nov 2018
    Location
    London, U.K.
    Posts
    99
    Location

    vba cell event change & call macro combination

    I need to run a macro that will unhide certain hidden columns when the active cell is no longer the active cell (users will click out of the active cell to deactivate it).

    I think I have found snippets of code for the 3 events:

    (a) unhide columns
    Columns("A:G") .EntireColumn.Hidden = False
    I've called this macro ShowConsole

    (b) active cell not active cell
    If ActiveCell.Address<>"$M$16" Then
    and

    (c) event change
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Me.Range("M16")) Is Nothing Then
    Application.EnableEvents = False
    Call ShowConsole
    Application.EnableEvents = True
    End If
    End Sub
    My problem is that I don't know how to bring all of this together.

  2. #2
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    If you want code that will hide columns A:G when M13 is selected and unhide them when it is de-selected. Code like this in the sheet's code module should work.
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        Me.Range("A:G").EntireColumn.Hidden = (Target.Address = "$M$16")
    End Sub

  3. #3
    VBAX Regular
    Joined
    Nov 2018
    Location
    London, U.K.
    Posts
    99
    Location
    Thank you

Posting Permissions

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