LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,533
Default select case in vba

Hein,

Thanks for your reply. I am glad that you made it work, despite my typo.

Regards,
Per

"Hein" skrev i meddelelsen
...
Per

Your method worked perfectly. The only problem I picked up was that I had
to
change the code
Range("Rng1").Hide = True
to
Range("Rng1").EntireRow.Hidden = True

Thanks very much.
Hein

"Per Jessen" wrote:

Hi

Sure you need to name B3 too.

Suppose you name B3 as DropDownRng then you can use this:

Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Me.Range("DropDownRng")) Is Nothing Then Exit Sub
Select Case Target.Value

Case "yes"
Application.ScreenUpdating = False
Range("Rng1").Hide = True
Application.ScreenUpdating = True
Case "no"
Application.ScreenUpdating = False
Range("Rng1").Hide = False
Application.ScreenUpdating = True
End Select

End Sub

Regards,
Per

"Hein" skrev i meddelelsen
...
I have tried the code as follows, but it doesn't work.

Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Me.Range("B3")) Is Nothing Then Exit Sub
Select Case Target.Value

Case "yes"
Application.ScreenUpdating = False
Range("Rng1").Hide = True
Application.ScreenUpdating = True
Case "no"
Application.ScreenUpdating = False
Range("Rng1").Hide = False
Application.ScreenUpdating = True
End Select

End Sub

I can see on the sheet that the range name has adjsuted if I insert a
row
above that. The other problem that I have is that if a row is inserted
above
B3(see above where the drop down menu is) then the drop down list moves
downwards from B3 to another cell (C4) and as such the macro won't
work. I
presume I need to name the cell and to define it in my macro as well.

Regards

"Per Jessen" wrote:

Hi Hein

You have to use named ranges as reference in your macro.

If you name A1:A10 as Rng1 and
name A11:A20 as Rng2, then user can insert a row, in say 10 and now
Rng1
will refer to A1:A11 and Rng2 will refer to A12:A21

In your macro use this:

Range("Rng1").Hide=true

Hopes this helps.
....
Per

"Hein" skrev i meddelelsen
...
Hi

I have a select case statement that refers to various cells in
different
rows from each other on a worksheet. Based on the answer that the
user
provides in these cells a function will be performed whereby a
specific
row
ranges will be hidden or not.

The problem that I have is that the user does have the option to
insert
rows
between these cells. This will now have the effect that a code that
was
linked to a specific range will now hide a different range that was
intended
as the ranges has now shifted downwards.

Is there anyway to overcome this problem?
Hein

.


.


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Select case Hein Excel Discussion (Misc queries) 2 October 22nd 08 07:06 AM
Case Select NoodNutt Excel Worksheet Functions 7 September 21st 08 02:10 AM
Case without Select Case error problem Ayo Excel Discussion (Misc queries) 2 May 16th 08 03:48 PM
Select Case Jeff Excel Discussion (Misc queries) 1 February 27th 06 02:56 PM
Need help on Select Case Susan Hayes Excel Worksheet Functions 1 November 3rd 04 10:25 PM


All times are GMT +1. The time now is 10:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"