#1   Report Post  
Posted to microsoft.public.excel.programming
JT JT is offline
external usenet poster
 
Posts: 234
Default private sub

I have the following private sub:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If ActiveCell = Range("H1") Or ActiveCell = Range("J1") Or ActiveCell =
Range("H2") Or ActiveCell = Range("J2") Then
Application.DisplayFormulaBar = False
Else
Application.DisplayFormulaBar = True
End If

End Sub

The intent is for the formula bar to be displayed unless the activecell is
in H1, H2, J1, or J2.

Right now the formula bar is only displayed if there is data in a cell. If
there is no data, the formalbar is hidden.

Any help would be appreciated......Thanks
--
JT
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default private sub

Try:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rng As Range
Set rng = Union(Range("H1:H2"), Range("J1:J2"))
With Application
.DisplayFormulaBar = (Intersect(Target, rng) Is Nothing)
End With
End Sub

Regards,
Greg

"JT" wrote:

I have the following private sub:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If ActiveCell = Range("H1") Or ActiveCell = Range("J1") Or ActiveCell =
Range("H2") Or ActiveCell = Range("J2") Then
Application.DisplayFormulaBar = False
Else
Application.DisplayFormulaBar = True
End If

End Sub

The intent is for the formula bar to be displayed unless the activecell is
in H1, H2, J1, or J2.

Right now the formula bar is only displayed if there is data in a cell. If
there is no data, the formalbar is hidden.

Any help would be appreciated......Thanks
--
JT

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default private sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Target, Range("H1,H2,J1,J2")) Is Nothing Then
Application.DisplayFormulaBar = False
Else
Application.DisplayFormulaBar = True
End If

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"JT" wrote in message
...
I have the following private sub:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If ActiveCell = Range("H1") Or ActiveCell = Range("J1") Or ActiveCell

=
Range("H2") Or ActiveCell = Range("J2") Then
Application.DisplayFormulaBar = False
Else
Application.DisplayFormulaBar = True
End If

End Sub

The intent is for the formula bar to be displayed unless the activecell is
in H1, H2, J1, or J2.

Right now the formula bar is only displayed if there is data in a cell.

If
there is no data, the formalbar is hidden.

Any help would be appreciated......Thanks
--
JT



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default private sub

The default property of a cell object is Value. Since you haven't specified
otherwise, you are currently comparing the Value of ActiveCell to the Values
of the 4 other cells. I gather what you really want to do is compare
Addresses. Here is one approach:

Select Case ActiveCell.Address
Case "$H$1", "$J$1", "$H$2", "$J$2"
Application.DisplayFormulaBar = False
Case Else
Application.DisplayFormulaBar = True
End Select

HTH,
--
George Nicholson

Remove 'Junk' from return address.


"JT" wrote in message
...
I have the following private sub:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If ActiveCell = Range("H1") Or ActiveCell = Range("J1") Or ActiveCell =
Range("H2") Or ActiveCell = Range("J2") Then
Application.DisplayFormulaBar = False
Else
Application.DisplayFormulaBar = True
End If

End Sub

The intent is for the formula bar to be displayed unless the activecell is
in H1, H2, J1, or J2.

Right now the formula bar is only displayed if there is data in a cell.
If
there is no data, the formalbar is hidden.

Any help would be appreciated......Thanks
--
JT



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
Private Sub() - Sub() CousinExcel Excel Discussion (Misc queries) 2 January 18th 10 01:39 PM
Private sub problem sby Excel Worksheet Functions 1 November 28th 07 04:50 PM
Private sub Mark New Users to Excel 3 April 6th 05 03:36 PM
Private Sub Running Other Private Sub Inadvertently Ross Culver Excel Programming 2 February 10th 05 07:17 PM
Private Sub Ronbo Excel Programming 11 January 13th 05 08:25 PM


All times are GMT +1. The time now is 04:16 AM.

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

About Us

"It's about Microsoft Excel"