Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Help with Worksheet_Change;section of code not woring as expected

The last if statement block in this subroutine: "If Target.Address() =
"$F$4"" Then is not responding. Can someone take a look and give me a hand
please? Nothing happens when I change the cell value from Yes to No or the
other way around.
Thanks

Private Sub Worksheet_Change(ByVal Target As Range)
Dim marketWS As Worksheet, rngmarketWS As Range

Set marketWS = Worksheets("Market_NLP Data")
Set rngmarketWS = marketWS.Range("A6:BG500")

If Target.Address() = "$A$2" Then
Application.EnableEvents = False
Application.ScreenUpdating = False
rngmarketWS.Select
With Selection
.ClearContents
.Interior.ColorIndex = 0
.Font.ColorIndex = 1
End With
Range("M1") = ""
Range("E2") = ""
Range("E2").Select

Select Case Target.Value

Case "CENTRAL PA"
With Range("E2").Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertInformation, Formula1:="NLP2,NLP3"
End With

Case "CONNECTICUT"
With Range("E2").Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertInformation, Formula1:="NLP1
Infill,NLP2,NLP3"
End With

Case "LONG ISLAND - NY"
With Range("E2").Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertInformation, Formula1:="NLP1
Infill,NLP3"
End With

Case "NEW ENGLAND MARKET"
With Range("E2").Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertInformation, Formula1:="NLP1
Infill,NLP2,NLP3"
End With

Case "NEW JERSEY NJ"
With Range("E2").Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertInformation, Formula1:="NLP1
Infill,NLP3"
End With

Case "NEW YORK NY"
With Range("E2").Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertInformation, Formula1:="NLP1 Infill"
End With

Case "NY (UPSTATE)"
With Range("E2").Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertInformation, Formula1:="NLP2,NLP3"
End With

Case "PHILDELPHIA PA"
With Range("E2").Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertInformation, Formula1:="NLP1
Infill,NLP2,NLP3"
End With

Case "VIRGINIA"
With Range("E2").Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertInformation, Formula1:="NLP2,NLP3"
End With

Case "WASHINGTON DC"
With Range("E2").Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertInformation, Formula1:="NLP1
Infill,NLP2,NLP3"
End With
End Select
Application.EnableEvents = True
Application.ScreenUpdating = True
End If

If Target.Address() = "$E$2" Then
Application.EnableEvents = False
Application.ScreenUpdating = False
rngmarketWS.Select
With Selection
.ClearContents
.Interior.ColorIndex = 0
.Font.ColorIndex = 1
End With
Call copyMarketData(Range("A2").Value, Target.Value)
Application.EnableEvents = True
Application.ScreenUpdating = True
End If

If Target.Address() = "$F$4" Then
'Application.EnableEvents = False
Application.ScreenUpdating = False
If Target.Value = "Yes" And Sheets("Data Corrections").Visible = False
Then
Sheets("Data Corrections").Visible = True
ElseIf Target.Value = "No" And Sheets("Data Corrections").Visible = True
Then
Sheets("Data Corrections").Visible = False
End If
'Application.EnableEvents = True
Application.ScreenUpdating = True
End If

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Help with Worksheet_Change;section of code not woring as expected

Disregard Post. Found the problem.

"Ayo" wrote:

The last if statement block in this subroutine: "If Target.Address() =
"$F$4"" Then is not responding. Can someone take a look and give me a hand
please? Nothing happens when I change the cell value from Yes to No or the
other way around.
Thanks

Private Sub Worksheet_Change(ByVal Target As Range)
Dim marketWS As Worksheet, rngmarketWS As Range

Set marketWS = Worksheets("Market_NLP Data")
Set rngmarketWS = marketWS.Range("A6:BG500")

If Target.Address() = "$A$2" Then
Application.EnableEvents = False
Application.ScreenUpdating = False
rngmarketWS.Select
With Selection
.ClearContents
.Interior.ColorIndex = 0
.Font.ColorIndex = 1
End With
Range("M1") = ""
Range("E2") = ""
Range("E2").Select

Select Case Target.Value

Case "CENTRAL PA"
With Range("E2").Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertInformation, Formula1:="NLP2,NLP3"
End With

Case "CONNECTICUT"
With Range("E2").Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertInformation, Formula1:="NLP1
Infill,NLP2,NLP3"
End With

Case "LONG ISLAND - NY"
With Range("E2").Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertInformation, Formula1:="NLP1
Infill,NLP3"
End With

Case "NEW ENGLAND MARKET"
With Range("E2").Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertInformation, Formula1:="NLP1
Infill,NLP2,NLP3"
End With

Case "NEW JERSEY NJ"
With Range("E2").Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertInformation, Formula1:="NLP1
Infill,NLP3"
End With

Case "NEW YORK NY"
With Range("E2").Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertInformation, Formula1:="NLP1 Infill"
End With

Case "NY (UPSTATE)"
With Range("E2").Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertInformation, Formula1:="NLP2,NLP3"
End With

Case "PHILDELPHIA PA"
With Range("E2").Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertInformation, Formula1:="NLP1
Infill,NLP2,NLP3"
End With

Case "VIRGINIA"
With Range("E2").Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertInformation, Formula1:="NLP2,NLP3"
End With

Case "WASHINGTON DC"
With Range("E2").Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertInformation, Formula1:="NLP1
Infill,NLP2,NLP3"
End With
End Select
Application.EnableEvents = True
Application.ScreenUpdating = True
End If

If Target.Address() = "$E$2" Then
Application.EnableEvents = False
Application.ScreenUpdating = False
rngmarketWS.Select
With Selection
.ClearContents
.Interior.ColorIndex = 0
.Font.ColorIndex = 1
End With
Call copyMarketData(Range("A2").Value, Target.Value)
Application.EnableEvents = True
Application.ScreenUpdating = True
End If

If Target.Address() = "$F$4" Then
'Application.EnableEvents = False
Application.ScreenUpdating = False
If Target.Value = "Yes" And Sheets("Data Corrections").Visible = False
Then
Sheets("Data Corrections").Visible = True
ElseIf Target.Value = "No" And Sheets("Data Corrections").Visible = True
Then
Sheets("Data Corrections").Visible = False
End If
'Application.EnableEvents = True
Application.ScreenUpdating = True
End If

End Sub

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
Run VBA code only worksheet change, but don't trigger worksheet_change event based on what the code does ker_01 Excel Programming 6 October 3rd 08 09:45 PM
Code not working as expected. Ayo Excel Discussion (Misc queries) 2 May 19th 08 07:08 PM
Worksheet_Change event not triggered as expected IanKR Excel Programming 4 October 17th 07 07:39 PM
Help !!! My code is not working as expected. Ayo Excel Discussion (Misc queries) 3 August 30th 07 10:39 PM


All times are GMT +1. The time now is 08:22 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"