Jack, but you wouldn't need the calculate routine, would you. The change
routine would take care of both the hiding or rows, as well as the picture
being visible...

I would however tentatively add a line in there

Private Sub Worksheet_Change(ByVal Target As Range)

    Dim oPic As Picture

    Application.EnableEvents=False
    If Target.Address = "B3" Then
        Select Case Target.Value
            Case Is = "DSL-Cleaner"
                Rows("1:156").Hidden = False
                Rows("157:208").Hidden = True
                Rows("209:256").Hidden = False
            Case Is = "DSN-DSL Cleaner"
                Rows("1:256").Hidden = False
        End Select

        Me.Pictures.Visible = False
        With Target

            For Each oPic In Me.Pictures
                If oPic.Name = .Text Then
                    oPic.Visible = True
                    oPic.Top = .Top
                    oPic.Left = .Left
                    Exit For
                End If
            Next oPic
        End With

    End If
Application.EnableEvents=True
End Sub

Sam Mathai Chacko

On Fri, Nov 11, 2011 at 9:46 PM, Sam Mathai Chacko <samde...@gmail.com>wrote:

> I believe you can merge it like this....
>
>
> Private Sub Worksheet_Change(ByVal Target As Range)
>
>     Dim oPic As Picture
>
>
>     If Target.Address = "B3" Then
>         Select Case Target.Value
>             Case Is = "DSL-Cleaner"
>                 Rows("1:156").Hidden = False
>                 Rows("157:208").Hidden = True
>                 Rows("209:256").Hidden = False
>             Case Is = "DSN-DSL Cleaner"
>                 Rows("1:256").Hidden = False
>         End Select
>
>         Me.Pictures.Visible = False
>         With Target
>
>             For Each oPic In Me.Pictures
>                 If oPic.Name = .Text Then
>                     oPic.Visible = True
>                     oPic.Top = .Top
>                     oPic.Left = .Left
>                     Exit For
>                 End If
>             Next oPic
>         End With
>
>     End If
>
> End Sub
>
> Regards,
>
> Sam Mathai Chacko
>
>
> On Fri, Nov 11, 2011 at 1:57 PM, Asa Rossoff <a...@lovetour.info> wrote:
>
>> Hi Jack,****
>>
>> ** **
>>
>> Does cell B3 contain a formula or are you entering a value directly?****
>>
>> ** **
>>
>> The Worksheet_Change event is triggered by changes that result from
>> direct entry.****
>>
>> The Worksheet_Calculate event is triggered by worksheet calculation.  If
>> there is a formula in B3, it will never be the "Target" in a
>> Worksheet_Change event, although any time it's resultant value changes (and
>> even more often than that, most likely), you would get a
>> Worksheet_Calculate event.****
>>
>> ** **
>>
>> Also, in your original post, the Worksheet_Change event you posted had a
>> couple of potential problems that I noticed:****
>>
>> ** **
>>
>> (1) The subroutine declaration was commented out with a single
>> apostrophe.   The event would be disabled like that, and the VBA code
>> without a Sub or Function declaration, and especially with an End Sub at
>> the end, would most likely confuse VBA.****
>>
>> ** **
>>
>> (2) You have the statement:****
>>
>> If Target.Address = "B3" Then ....****
>>
>> ** **
>>
>> Since more than one cell can change at one time (copy/paste, fill, ?),
>> the Address property will refer to all of the changed cells.  Also, The
>> .Address property will never = "B3".  It could = "$B$3" though.****
>>
>> ** **
>>
>> The usual way of checking if a particular cell was changed in the
>> Worksheet_Change event is to see if the cell intersects with Target:****
>>
>> If Not Application.Intersect(Range("B3"), Target) Is Nothing Then ....***
>> *
>>
>> ** **
>>
>> (3) You have the statement:****
>>
>> Select Case Target.Value****
>>
>>     Case Is = "DSL-Cleaner"****
>>
>> ....****
>>
>> ** **
>>
>> If Target is a range of more than one cell, comparing Target.Value to a
>> string will result in a type mismatch error, since Target.Value will be an
>> array of values in that case.  Admittedly this is inside your If
>> Target.Address="B3" block, which if you changed to ="$B$3" would run
>> your code if ONLY cell B3 was changed, and with only one cell changed, and
>> your Select statement inside that If block it will never execute under
>> other circumstances, and you would avoid an error.  I recommend the
>> Intersect method though.  In which case, you might get a type mismatch, and
>> also you would be checking the value of who knows what other cells you
>> aren't interested in, too.****
>>
>> ** **
>>
>> You could use:****
>>
>> Select Case Range("B3").Value****
>>
>> ....****
>>
>> ** **
>>
>> Asa****
>>
>> ** **
>>
>> ** **
>>
>> ** **
>>
>> -----Original Message-----
>> From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com]
>> On Behalf Of Jack
>> Sent: Thursday, November 10, 2011 12:12 PM
>> To: MS EXCEL AND VBA MACROS
>> Subject: Re: $$Excel-Macros$$ Calling multiple type subroutines****
>>
>> ** **
>>
>> I apologize for the lack of clarity. I blame it on being new to macros***
>> *
>>
>> still, lol.****
>>
>> ** **
>>
>> The first routine is a:****
>>
>> ** **
>>
>> Private Sub Worksheet_Calculate()****
>>
>> ** **
>>
>> Dim oPic As Picture****
>>
>> Me.Pictures.Visible = False****
>>
>> With Range("B3")****
>>
>>     For Each oPic In Me.Pictures****
>>
>>         If oPic.Name = .Text Then****
>>
>>             oPic.Visible = True****
>>
>>             oPic.Top = .Top****
>>
>>             oPic.Left = .Left****
>>
>>             Exit For****
>>
>>         End If****
>>
>>             Next oPic****
>>
>> End With****
>>
>> End Sub****
>>
>> ** **
>>
>> I forgot to mention that I pulled this routine from a web example.****
>>
>> ** **
>>
>> The problem I'm having is that when whichever routine I put first,****
>>
>> gets priority and it works. However the 2nd one does not. Putting the****
>>
>> picture change routine first, it does change the pictures. However,****
>>
>> the 2nd routine to hide rows does not work. I would just like to know****
>>
>> how to get them both to work since they are independent routines being***
>> *
>>
>> that they are 2 different types of sub routines****
>>
>> ** **
>>
>> Private Sub Worksheet_Calculate()****
>>
>> Private Sub Worksheet_Change(ByVal Target As Range)****
>>
>> ** **
>>
>> I'm not sure how to work it to where both work simultaneously.****
>>
>> ** **
>>
>> Jack****
>>
>> ** **
>>
>> On Nov 10, 11:28 am, Sam Mathai Chacko <samde...@gmail.com> wrote:****
>>
>> > The Worksheet change routine is automatically triggered when there is a
>> ****
>>
>> > change (change in value/modification of value etc) in 1 or more cells**
>> **
>>
>> > within THAT sheet. So you don't really CALL it, it GETS called, in other
>> ****
>>
>> > words, TRIGGERED.****
>>
>> >** **
>>
>> > For the first routine, the context is not clear enough to judge when and
>> ****
>>
>> > how it has to be called, so a bit more clarity may help****
>>
>> >** **
>>
>> > Regards,****
>>
>> > Sam****
>>
>> >** **
>>
>> >** **
>>
>> >** **
>>
>> >** **
>>
>> >** **
>>
>> >** **
>>
>> >** **
>>
>> >** **
>>
>> >** **
>>
>> > On Thu, Nov 10, 2011 at 8:53 PM, Jack <aan...@gmail.com> wrote:****
>>
>> > > I am new to macros. I tried searching the internet for the answer but
>> ****
>>
>> > > the limited experience didn't quite help me find my answer. I hope you
>> ****
>>
>> > > guys can figure it out.****
>>
>> >** **
>>
>> > > I have 2 sub routines. 1 that pulls a photo and another that hides***
>> *
>>
>> > > rows based on a value from cell B3. I tried to the Call option but***
>> *
>>
>> > > wasn't quite sure how to pull it together. Below are my 2 routines:**
>> **
>>
>> >** **
>>
>> > > Dim oPic As Picture****
>>
>> > > Me.Pictures.Visible = False****
>>
>> > > With Range("B3")****
>>
>> > >    For Each oPic In Me.Pictures****
>>
>> > >        If oPic.Name = .Text Then****
>>
>> > >            oPic.Visible = True****
>>
>> > >            oPic.Top = .Top****
>>
>> > >            oPic.Left = .Left****
>>
>> > >            Exit For****
>>
>> > >        End If****
>>
>> > >            Next oPic****
>>
>> > > End With****
>>
>> > > End Sub****
>>
>> >** **
>>
>> > >
>> ------------------------------------------------------------------------------
>> ****
>>
>> > > 'Private Sub Worksheet_Change(ByVal Target As Range)****
>>
>> >** **
>>
>> > > If Target.Address = "B3" Then****
>>
>> > >   Select Case Target.Value****
>>
>> > >       Case Is = "DSL-Cleaner"****
>>
>> > >           Rows("1:156").Hidden = False****
>>
>> > >           Rows("157:208").Hidden = True****
>>
>> > >           Rows("209:256").Hidden = False****
>>
>> > >       Case Is = "DSN-DSL Cleaner"****
>>
>> > >           Rows("1:256").Hidden = False****
>>
>> > >   End Select****
>>
>> > > End If****
>>
>> > > End Sub****
>>
>> >** **
>>
>> > > I greatly appreciate the help.****
>>
>> >** **
>>
>> > > --****
>>
>> > > FORUM RULES (934+ members already BANNED for violation)****
>>
>> >** **
>>
>> > > 1) Use concise, accurate thread titles. Poor thread titles, like
>> Please****
>>
>> > > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need
>> Advice****
>>
>> > > will not get quick attention or may not be answered.****
>>
>> >** **
>>
>> > > 2) Don't post a question in the thread of another member.****
>>
>> >** **
>>
>> > > 3) Don't post questions regarding breaking or bypassing any security*
>> ***
>>
>> > > measure.****
>>
>> >** **
>>
>> > > 4) Acknowledge the responses you receive, good or bad.****
>>
>> >** **
>>
>> > > 5)  Cross-promotion of, or links to, forums competitive to this forum
>> in****
>>
>> > > signatures are prohibited.****
>>
>> >** **
>>
>> > > NOTE  : Don't ever post personal or confidential data in a workbook.
>> Forum****
>>
>> > > owners and members are not responsible for any loss.****
>>
>> >** **
>>
>> > >
>> ------------------------------------------------------------------------------------------------------
>> ****
>>
>> > > To post to this group, send email to excel-macros@googlegroups.com***
>> *
>>
>> >** **
>>
>> > --****
>>
>> > Sam Mathai Chacko****
>>
>> ** **
>>
>> -- ****
>>
>> FORUM RULES (934+ members already BANNED for violation)****
>>
>> ** **
>>
>> 1) Use concise, accurate thread titles. Poor thread titles, like Please
>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
>> will not get quick attention or may not be answered.****
>>
>> ** **
>>
>> 2) Don't post a question in the thread of another member.****
>>
>> ** **
>>
>> 3) Don't post questions regarding breaking or bypassing any security
>> measure.****
>>
>> ** **
>>
>> 4) Acknowledge the responses you receive, good or bad.****
>>
>> ** **
>>
>> 5)  Cross-promotion of, or links to, forums competitive to this forum in
>> signatures are prohibited. ****
>>
>> ** **
>>
>> NOTE  : Don't ever post personal or confidential data in a workbook.
>> Forum owners and members are not responsible for any loss.****
>>
>> ** **
>>
>>
>> ------------------------------------------------------------------------------------------------------
>> ****
>>
>> To post to this group, send email to excel-macros@googlegroups.com****
>>
>> --
>> FORUM RULES (934+ members already BANNED for violation)
>>
>> 1) Use concise, accurate thread titles. Poor thread titles, like Please
>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
>> will not get quick attention or may not be answered.
>>
>> 2) Don't post a question in the thread of another member.
>>
>> 3) Don't post questions regarding breaking or bypassing any security
>> measure.
>>
>> 4) Acknowledge the responses you receive, good or bad.
>>
>> 5) Cross-promotion of, or links to, forums competitive to this forum in
>> signatures are prohibited.
>>
>> NOTE : Don't ever post personal or confidential data in a workbook. Forum
>> owners and members are not responsible for any loss.
>>
>>
>> ------------------------------------------------------------------------------------------------------
>> To post to this group, send email to excel-macros@googlegroups.com
>>
>
>
>
> --
> Sam Mathai Chacko
>



-- 
Sam Mathai Chacko

-- 
FORUM RULES (934+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

Reply via email to