ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Detecting active customview (https://www.excelbanter.com/excel-programming/319019-detecting-active-customview.html)

Bart

Detecting active customview
 
Hello

I have to create a piece of code wich makes a few buttons visible or in
visible depending of te active customview that is selected on a sheet.It has
to be something like this:

Private Sub Worksheet_Activate()
If (ACTIVECUSTOMVIEW = view1) then
CommandButton1.Visible = False
End If

If (ACTIVECUSTOMVIEW = view2) then
CommandButton1.Visible = True
End If
End Sub


Thanks in advance...




Rob van Gelder[_4_]

Detecting active customview
 
I don't think there is an easy way to detect the active custom view.

What I've suggested in the past (untested) is to hide certain rows or
columns.
Look for the hidden row to detect whether a custom view has been applied or
not.
Pretty lame way to get the active custom view, but I can suggest nothing
else.

PS.
Watch out with Custom Views filters and frozen panes:
To see what I mean:

My Column Header
a
b
c
d

freeze panes on "My Column Header" 1:1
filter on values = b
save as custom view
unfilter
apply that custom view
unfilter

now 1:2 are frozen - that's annoying.


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Bart" wrote in message
...
Hello

I have to create a piece of code wich makes a few buttons visible or in
visible depending of te active customview that is selected on a sheet.It
has
to be something like this:

Private Sub Worksheet_Activate()
If (ACTIVECUSTOMVIEW = view1) then
CommandButton1.Visible = False
End If

If (ACTIVECUSTOMVIEW = view2) then
CommandButton1.Visible = True
End If
End Sub


Thanks in advance...






Bart

Detecting active customview
 
Maybe it is possible to use a sort of global variable, so that when i change
to a different custom view on an other sheet , i also change this global
variable?
And when a worksheet becoms active i test this global variable, is something
like that possible?

"Rob van Gelder" wrote:

I don't think there is an easy way to detect the active custom view.

What I've suggested in the past (untested) is to hide certain rows or
columns.
Look for the hidden row to detect whether a custom view has been applied or
not.
Pretty lame way to get the active custom view, but I can suggest nothing
else.

PS.
Watch out with Custom Views filters and frozen panes:
To see what I mean:

My Column Header
a
b
c
d

freeze panes on "My Column Header" 1:1
filter on values = b
save as custom view
unfilter
apply that custom view
unfilter

now 1:2 are frozen - that's annoying.


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Bart" wrote in message
...
Hello

I have to create a piece of code wich makes a few buttons visible or in
visible depending of te active customview that is selected on a sheet.It
has
to be something like this:

Private Sub Worksheet_Activate()
If (ACTIVECUSTOMVIEW = view1) then
CommandButton1.Visible = False
End If

If (ACTIVECUSTOMVIEW = view2) then
CommandButton1.Visible = True
End If
End Sub


Thanks in advance...







Dave Peterson[_5_]

Detecting active customview
 
Just my thoughts...

You could provide the user with a macro that shows what customviews you want to
allow. And after they chose it, you could keep it in a global variable (or even
a cell in a hidden worksheet if the workbook gets closed).

But after the user changes views, they could unhide any column they wanted. So
your variable would be out of sync. (And the user could change to any view they
wanted negating the accuracy of that variable, too.)


Bart wrote:

Maybe it is possible to use a sort of global variable, so that when i change
to a different custom view on an other sheet , i also change this global
variable?
And when a worksheet becoms active i test this global variable, is something
like that possible?

"Rob van Gelder" wrote:

I don't think there is an easy way to detect the active custom view.

What I've suggested in the past (untested) is to hide certain rows or
columns.
Look for the hidden row to detect whether a custom view has been applied or
not.
Pretty lame way to get the active custom view, but I can suggest nothing
else.

PS.
Watch out with Custom Views filters and frozen panes:
To see what I mean:

My Column Header
a
b
c
d

freeze panes on "My Column Header" 1:1
filter on values = b
save as custom view
unfilter
apply that custom view
unfilter

now 1:2 are frozen - that's annoying.


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Bart" wrote in message
...
Hello

I have to create a piece of code wich makes a few buttons visible or in
visible depending of te active customview that is selected on a sheet.It
has
to be something like this:

Private Sub Worksheet_Activate()
If (ACTIVECUSTOMVIEW = view1) then
CommandButton1.Visible = False
End If

If (ACTIVECUSTOMVIEW = view2) then
CommandButton1.Visible = True
End If
End Sub


Thanks in advance...







--

Dave Peterson

Rob van Gelder[_4_]

Detecting active customview
 
I agree.
The user could override any hidden columns or indicators that a custom view
has been selected.

As said, I don't think there is an easy way to detect it.

What I've resorted to in the past is to do all the custom view type
formatting by code and then run them as macros.
In other words, Custom View by code.
You get a lot more control over formatting that way too.


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Dave Peterson" wrote in message
...
Just my thoughts...

You could provide the user with a macro that shows what customviews you
want to
allow. And after they chose it, you could keep it in a global variable
(or even
a cell in a hidden worksheet if the workbook gets closed).

But after the user changes views, they could unhide any column they
wanted. So
your variable would be out of sync. (And the user could change to any
view they
wanted negating the accuracy of that variable, too.)


Bart wrote:

Maybe it is possible to use a sort of global variable, so that when i
change
to a different custom view on an other sheet , i also change this global
variable?
And when a worksheet becoms active i test this global variable, is
something
like that possible?

"Rob van Gelder" wrote:

I don't think there is an easy way to detect the active custom view.

What I've suggested in the past (untested) is to hide certain rows or
columns.
Look for the hidden row to detect whether a custom view has been
applied or
not.
Pretty lame way to get the active custom view, but I can suggest
nothing
else.

PS.
Watch out with Custom Views filters and frozen panes:
To see what I mean:

My Column Header
a
b
c
d

freeze panes on "My Column Header" 1:1
filter on values = b
save as custom view
unfilter
apply that custom view
unfilter

now 1:2 are frozen - that's annoying.


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Bart" wrote in message
...
Hello

I have to create a piece of code wich makes a few buttons visible or
in
visible depending of te active customview that is selected on a
sheet.It
has
to be something like this:

Private Sub Worksheet_Activate()
If (ACTIVECUSTOMVIEW = view1) then
CommandButton1.Visible = False
End If

If (ACTIVECUSTOMVIEW = view2) then
CommandButton1.Visible = True
End If
End Sub


Thanks in advance...







--

Dave Peterson





All times are GMT +1. The time now is 07:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com