ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   vb dummy - two routines (https://www.excelbanter.com/excel-programming/332186-vbulletin-dummy-two-routines.html)

Greg

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

Robin Hammond[_2_]

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




Norie

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


Piranha[_11_]

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


Greg

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


Norie

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


Greg

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




All times are GMT +1. The time now is 11:22 PM.

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