PC Review


Reply
Thread Tools Rate Thread

and, or in vbe

 
 
N+
Guest
Posts: n/a
 
      3rd May 2008
hi all !! how can i do the AND , OR function of worksheet
in the vbe ??
ty for helping !!
paolo
 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      3rd May 2008
A bit more explanation as to what you are doing and what you have tried.


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"N+" <(E-Mail Removed)> wrote in message
news949A3F4-E4E4-4342-9378-(E-Mail Removed)...
> hi all !! how can i do the AND , OR function of worksheet
> in the vbe ??
> ty for helping !!
> paolo


 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      3rd May 2008
In VB, And and Or are not functions, they are operators... you would use
them in much the same way as you would use plus, minus, multiply, etc. For
example...

If (A > 4) And (B <= 10) Then

Rick


"N+" <(E-Mail Removed)> wrote in message
news949A3F4-E4E4-4342-9378-(E-Mail Removed)...
> hi all !! how can i do the AND , OR function of worksheet
> in the vbe ??
> ty for helping !!
> paolo


 
Reply With Quote
 
Norman Jones
Guest
Posts: n/a
 
      3rd May 2008
Hi Paolo,

Perhaps the following procedure will
be of assistance:

'===========>>
Public Sub Tester()
Dim Rng As Range
Dim rng2 As Range

With ActiveSheet
Set Rng = .Range("A1")
Set rng2 = .Range("A2")
End With

Rng.Value = 10
rng2 = 20

If Rng >= 10 _
And rng2 >= 10 Then
MsgBox Prompt:="Both >= 9"
End If

If Rng >= 10 _
Or rng2 >= 10 Then
MsgBox Prompt:="At least one value >= 10"
End If

End Sub
'<<===========



---
Regards.
Norman


"N+" <(E-Mail Removed)> wrote in message
news949A3F4-E4E4-4342-9378-(E-Mail Removed)...
> hi all !! how can i do the AND , OR function of worksheet
> in the vbe ??
> ty for helping !!
> paolo


 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      3rd May 2008
I'm not sure what you're asking. VBA has its own 'And' and 'Or' comparison
operators. If you want to use the worksheet function, you can do something
like

Application.WorksheetFunction.Or

If you want to create a formula in a cell, try something like

Dim F As String
F = "=OR(A1,B1)"
Range("C1").Formula = F


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



"N+" <(E-Mail Removed)> wrote in message
news949A3F4-E4E4-4342-9378-(E-Mail Removed)...
> hi all !! how can i do the AND , OR function of worksheet
> in the vbe ??
> ty for helping !!
> paolo


 
Reply With Quote
 
Gary''s Student
Guest
Posts: n/a
 
      3rd May 2008
AND and OR are operators in VBA, not functions in the worksheet:

Sub and_or()
If Range("A1").Value = 1 And Range("A2").Value = 1 Then
MsgBox ("Both are one")
End If

If Range("A1").Value = 1 Or Range("A2").Value = 1 Then
MsgBox ("At least one is one")
End If

End Sub

--
Gary''s Student - gsnu200783


"N+" wrote:

> hi all !! how can i do the AND , OR function of worksheet
> in the vbe ??
> ty for helping !!
> paolo

 
Reply With Quote
 
N+
Guest
Posts: n/a
 
      3rd May 2008


'''''''''''DONE TY !!'''''''''''''''

"Gary''s Student" wrote:

> AND and OR are operators in VBA, not functions in the worksheet:
>
> Sub and_or()
> If Range("A1").Value = 1 And Range("A2").Value = 1 Then
> MsgBox ("Both are one")
> End If
>
> If Range("A1").Value = 1 Or Range("A2").Value = 1 Then
> MsgBox ("At least one is one")
> End If
>
> End Sub
>
> --
> Gary''s Student - gsnu200783
>
>
> "N+" wrote:
>
> > hi all !! how can i do the AND , OR function of worksheet
> > in the vbe ??
> > ty for helping !!
> > paolo

 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      3rd May 2008
Set rng = Selection
For Each cell In rng
If cell.Text = "0" Or cell.Text = "" And _
cell.Offset(0, 3).Value = "hoohah" Then
cell.EntireRow.Interior.ColorIndex = 6
End If
Next


Gord Dibben MS Excel MVP

On Sat, 3 May 2008 11:15:00 -0700, N+ <(E-Mail Removed)> wrote:

>hi all !! how can i do the AND , OR function of worksheet
>in the vbe ??
>ty for helping !!
>paolo


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:37 AM.