+ Reply to Thread
Results 1 to 7 of 7

vb dummy - two routines

  1. #1
    Greg
    Guest

    vb dummy - two routines

    I found a vb program and modified it to work on my spreadsheet. It's
    activated based on cell a1. I copied it again and changed it to activate on
    g1. a1 gives me customers and g1 gives me the customers by the designated
    month. Both work individually but not pasted in the same book. I'm a pure
    rookie. Any suggestions?
    Thanks, Greg

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Greg

    Can we see the code you are using?

    And what are you trying to do?

  3. #3
    Robin Hammond
    Guest

    Re: vb dummy - two routines

    Greg,

    Post the code and we might have a chance of helping you.

    Robin Hammond
    www.enhanceddatasystems.com

    "Greg" <[email protected]> wrote in message
    news:[email protected]...
    >I found a vb program and modified it to work on my spreadsheet. It's
    > activated based on cell a1. I copied it again and changed it to activate
    > on
    > g1. a1 gives me customers and g1 gives me the customers by the designated
    > month. Both work individually but not pasted in the same book. I'm a
    > pure
    > rookie. Any suggestions?
    > Thanks, Greg




  4. #4
    Forum Contributor
    Join Date
    02-26-2005
    Posts
    175
    Quote Originally Posted by Greg
    I found a vb program and modified it to work on my spreadsheet. It's
    activated based on cell a1. I copied it again and changed it to activate on
    g1. a1 gives me customers and g1 gives me the customers by the designated
    month. Both work individually but not pasted in the same book. I'm a pure
    rookie. Any suggestions?
    Thanks, Greg
    Greg,
    If you copied and pasted it, They both probably have the same name,
    which you can't use together. If so, just change the name of the second
    macro, then you can use them in the same book.
    Dave

  5. #5
    Greg
    Guest

    RE: vb dummy - two routines

    here is the script:
    Option Explicit


    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim r As Long

    If Target.Count > 1 Then Exit Sub
    If Target.Address = "$C$16" Then
    If ActiveSheet.FilterMode Then
    ActiveSheet.ShowAllData
    End If
    r = Cells(Rows.Count, 1).End(xlUp).Row
    If Target.Value = Sheets("Lists").Range("A1").Value Then
    Sheets("Lists").Range("C2").Value = ""
    Else
    Sheets("Lists").Range("C2").Value = Target.Value
    End If

    Range("a20:P" & r).AdvancedFilter Action:=xlFilterInPlace, _
    CriteriaRange:=Sheets("Lists").Range("C1:C2"), Unique:=False
    End If
    End Sub

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim r As Long

    If Target.Count > 1 Then Exit Sub
    If Target.Address = "$G$16" Then
    If ActiveSheet.FilterMode Then
    ActiveSheet.ShowAllData
    End If
    r = Cells(Rows.Count, 1).End(xlUp).Row
    If Target.Value = Sheets("Lists").Range("D1").Value Then
    Sheets("Lists").Range("E2").Value = ""
    Else
    Sheets("Lists").Range("E2").Value = Target.Value
    End If

    Range("a20:P" & r).AdvancedFilter Action:=xlFilterInPlace, _
    CriteriaRange:=Sheets("Lists").Range("f1:f2"), Unique:=False
    End If
    End Sub


    thanks, greg


    "Greg" wrote:

    > I found a vb program and modified it to work on my spreadsheet. It's
    > activated based on cell a1. I copied it again and changed it to activate on
    > g1. a1 gives me customers and g1 gives me the customers by the designated
    > month. Both work individually but not pasted in the same book. I'm a pure
    > rookie. Any suggestions?
    > Thanks, Greg


  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Greg

    You can't have 2 change events like that for the same worksheet.

    You could combine that code.
    Please Login or Register  to view this content.

  7. #7
    Greg
    Guest

    Re: vb dummy - two routines

    Norie,
    Perfect! Thanks....Greg

    "Norie" wrote:

    >
    > Greg
    >
    > You can't have 2 change events like that for the same worksheet.
    >
    > You could combine that code.
    >
    > Code:
    > --------------------
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    > Dim r As Long
    >
    > If Target.Count > 1 Then Exit Sub
    >
    > If Target.Address = "$C$16" Then
    > If ActiveSheet.FilterMode Then
    > ActiveSheet.ShowAllData
    > End If
    > r = Cells(Rows.Count, 1).End(xlUp).Row
    > If Target.Value = Sheets("Lists").Range("A1").Value Then
    > Sheets("Lists").Range("C2").Value = ""
    > Else
    > Sheets("Lists").Range("C2").Value = Target.Value
    > End If
    >
    > Range("a20:P" & r).AdvancedFilter Action:=xlFilterInPlace, _
    > CriteriaRange:=Sheets("Lists").Range("C1:C2"), Unique:=False
    > End If
    >
    > If Target.Address = "$G$16" Then
    >
    > If ActiveSheet.FilterMode Then
    > ActiveSheet.ShowAllData
    > End If
    > r = Cells(Rows.Count, 1).End(xlUp).Row
    > If Target.Value = Sheets("Lists").Range("D1").Value Then
    > Sheets("Lists").Range("E2").Value = ""
    > Else
    > Sheets("Lists").Range("E2").Value = Target.Value
    > End If
    >
    > Range("a20:P" & r).AdvancedFilter Action:=xlFilterInPlace, _
    > CriteriaRange:=Sheets("Lists").Range("f1:f2"), Unique:=False
    > End If
    >
    > End Sub
    >
    >
    > --------------------
    >
    >
    > --
    > Norie
    > ------------------------------------------------------------------------
    > Norie's Profile: http://www.excelforum.com/member.php...o&userid=19362
    > View this thread: http://www.excelforum.com/showthread...hreadid=380266
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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