Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 331
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default vb dummy - two routines

Greg,

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

Robin Hammond
www.enhanceddatasystems.com

"Greg" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default vb dummy - two routines


Greg

Can we see the code you are using?

And what are you trying to do

--
Nori
-----------------------------------------------------------------------
Norie's Profile: http://www.excelforum.com/member.php...fo&userid=1936
View this thread: http://www.excelforum.com/showthread.php?threadid=38026

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default vb dummy - two routines


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

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


--
Piranha
------------------------------------------------------------------------
Piranha's Profile: http://www.excelforum.com/member.php...o&userid=20435
View this thread: http://www.excelforum.com/showthread...hreadid=380266

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 331
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default vb dummy - two routines


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

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 331
Default 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
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
Excel VBA Wookbook Routines Michael Kintner Excel Discussion (Misc queries) 1 August 7th 07 02:16 PM
VBA - sub routines Help please Richard Wrigley New Users to Excel 3 November 23rd 06 03:06 AM
VBA routines - help please Richard Wrigley Excel Discussion (Misc queries) 1 November 22nd 06 07:15 PM
Removing VBA routines Robin Clay[_2_] Excel Programming 2 October 14th 03 05:44 PM
api call routines anthony Excel Programming 2 July 21st 03 02:00 PM


All times are GMT +1. The time now is 02:45 AM.

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

About Us

"It's about Microsoft Excel"