ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   program activation (https://www.excelbanter.com/excel-programming/281038-program-activation.html)

Lawson

program activation
 
this program currently runs when the user is working
anywhere on the spreadsheet, but i only want the program
to run if the user enters something in range g251.
suggestions?

Private Sub Worksheet_SelectionChange(ByVal Target As
Range)
If Len(Range("h251")) 10 Then
Range("g251:h251").Borders(xlEdgeLeft).Weight = xlMedium:
Range("g251:h251").Borders(xlEdgeTop).Weight = xlMedium:
Range("g251:h251").Borders(xlEdgeBottom).Weight =
xlMedium: Range("g251").Interior.ColorIndex = 6
Else
Range("g251").Interior.ColorIndex = 0: Range
("g251").Borders(xlEdgeLeft).LineStyle = xlNone: Range
("g251").Borders(xlEdgeTop).LineStyle = xlNone: Range
("g251").Borders(xlEdgeBottom).LineStyle = xlNone
End If
End Sub

Don Guillett[_4_]

program activation
 
why not a worksheet_change instead
if target.address<"$G$251" then exit sub


"Lawson" wrote in message
...
this program currently runs when the user is working
anywhere on the spreadsheet, but i only want the program
to run if the user enters something in range g251.
suggestions?

Private Sub Worksheet_SelectionChange(ByVal Target As
Range)
If Len(Range("h251")) 10 Then
Range("g251:h251").Borders(xlEdgeLeft).Weight = xlMedium:
Range("g251:h251").Borders(xlEdgeTop).Weight = xlMedium:
Range("g251:h251").Borders(xlEdgeBottom).Weight =
xlMedium: Range("g251").Interior.ColorIndex = 6
Else
Range("g251").Interior.ColorIndex = 0: Range
("g251").Borders(xlEdgeLeft).LineStyle = xlNone: Range
("g251").Borders(xlEdgeTop).LineStyle = xlNone: Range
("g251").Borders(xlEdgeBottom).LineStyle = xlNone
End If
End Sub




Tom Ogilvy

program activation
 
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$G$251" Then
If Len(Range("h251")) 10 Then
Range("g251:h251").Borders(xlEdgeLeft).Weight = xlMedium:
Range("g251:h251").Borders(xlEdgeTop).Weight = xlMedium:
Range("g251:h251").Borders(xlEdgeBottom).Weight =
xlMedium: Range("g251").Interior.ColorIndex = 6
Else
Range("g251").Interior.ColorIndex = 0: Range
("g251").Borders(xlEdgeLeft).LineStyle = xlNone: Range
("g251").Borders(xlEdgeTop).LineStyle = xlNone: Range
("g251").Borders(xlEdgeBottom).LineStyle = xlNone
End If
End If
End Sub


"Lawson" wrote in message
...
this program currently runs when the user is working
anywhere on the spreadsheet, but i only want the program
to run if the user enters something in range g251.
suggestions?

Private Sub Worksheet_SelectionChange(ByVal Target As
Range)
If Len(Range("h251")) 10 Then
Range("g251:h251").Borders(xlEdgeLeft).Weight = xlMedium:
Range("g251:h251").Borders(xlEdgeTop).Weight = xlMedium:
Range("g251:h251").Borders(xlEdgeBottom).Weight =
xlMedium: Range("g251").Interior.ColorIndex = 6
Else
Range("g251").Interior.ColorIndex = 0: Range
("g251").Borders(xlEdgeLeft).LineStyle = xlNone: Range
("g251").Borders(xlEdgeTop).LineStyle = xlNone: Range
("g251").Borders(xlEdgeBottom).LineStyle = xlNone
End If
End Sub





All times are GMT +1. The time now is 06:12 PM.

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