Group:  Microsoft Excel ยป microsoft.public.excel
Thread: using `if` a value is between

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

using `if` a value is between
"FennisDuck" <Fennis[ at ]Menace.AOL.com> 11.09.2006 12:02:09
I am using zz as my variable
what I want to do is
if zz is between 7 and 10 then print out a range within a sheet
is the print range line correct ????????
any assistance appreciated

If ZZ = >1 or < =7 Then ' check value of zz
Range("A2:G36").PrintOut.SelectedSheets ' Print selected range

If ZZ > 8 or < 14Then
Range("A2:G36").PrintOut.SelectedSheets


Re: using `if` a value is between
"Pete_UK" <pashurst[ at ]auditel.net> 11.09.2006 12:20:00
You will need to use AND and get the operators in the correct syntax:

If zz >=1 And zz <= 7 Then
etc

which means if zz is between 1 and 7 (inclusive) then do something ...

Hope this helps.

Pete

FennisDuck wrote:
[Quoted Text]
> I am using zz as my variable
> what I want to do is
> if zz is between 7 and 10 then print out a range within a sheet
> is the print range line correct ????????
> any assistance appreciated
>
> If ZZ = >1 or < =7 Then ' check value of zz
> Range("A2:G36").PrintOut.SelectedSheets ' Print selected range
>
> If ZZ > 8 or < 14Then
> Range("A2:G36").PrintOut.SelectedSheets

Re: using `if` a value is between
Dave Peterson <petersod[ at ]verizonXSPAM.net> 11.09.2006 12:30:56
Maybe you want:

Activesheet.Range("A2:G36").PrintOut

And you seem to be printing the same range no matter what your value in zz is.
(1 through 14).

FennisDuck wrote:
[Quoted Text]
>
> I am using zz as my variable
> what I want to do is
> if zz is between 7 and 10 then print out a range within a sheet
> is the print range line correct ????????
> any assistance appreciated
>
> If ZZ = >1 or < =7 Then ' check value of zz
> Range("A2:G36").PrintOut.SelectedSheets ' Print selected range
>
> If ZZ > 8 or < 14Then
> Range("A2:G36").PrintOut.SelectedSheets

--

Dave Peterson
Re: using `if` a value is between - A Thank You
"FennisDuck" <Fennis[ at ]Menace.AOL.com> 11.09.2006 20:21:20
Thank you
Pete Uk and Dave Peterson
in respect of the range being the same unfortunately one of the downsides of
copy `n` paste.
Once again thankyou for taking the time to look and reply with respective
formulas

"Dave Peterson" <petersod[ at ]verizonXSPAM.net> wrote in message
news:45055700.1BFE866A[ at ]verizonXSPAM.net...
[Quoted Text]
> Maybe you want:
>
> Activesheet.Range("A2:G36").PrintOut
>
> And you seem to be printing the same range no matter what your value in zz
> is.
> (1 through 14).
>
> FennisDuck wrote:
>>
>> I am using zz as my variable
>> what I want to do is
>> if zz is between 7 and 10 then print out a range within a sheet
>> is the print range line correct ????????
>> any assistance appreciated
>>
>> If ZZ = >1 or < =7 Then ' check value of zz
>> Range("A2:G36").PrintOut.SelectedSheets ' Print selected range
>>
>> If ZZ > 8 or < 14Then
>> Range("A2:G36").PrintOut.SelectedSheets
>
> --
>
> Dave Peterson


Re: using `if` a value is between - still need help plz
"FennisDuck" <Fennis[ at ]Menace.AOL.com> 11.09.2006 21:23:02
Sorry Pete UK
It will only print range when zz is between 1 & 7 anything above that there
is no print
but it is appreciated , thank you

Sub PrintList()

' PrintList Macro



Sheets("w002").Select

ZZ = Worksheets("w001").Range("a27").Value ' get value . this is variable



If ZZ => 1 And ZZ <=7 Then ' Only hthis range will
print when value is 1 to 7

ActiveSheet.Range("A2:G36").PrintOut

If ZZ => 8 And ZZ < =14 Then

ActiveSheet.Range("A2:G71").PrintOut

If ZZ => 15 And ZZ < =22 Then

ActiveSheet.Range("a72:G106").PrintOut



End If

End If

End If



End Sub



"Pete_UK" <pashurst[ at ]auditel.net> wrote in message
news:1157977200.204775.214820[ at ]h48g2000cwc.googlegroups.com...
[Quoted Text]
> You will need to use AND and get the operators in the correct syntax:
>
> If zz >=1 And zz <= 7 Then
> etc
>
> which means if zz is between 1 and 7 (inclusive) then do something ...
>
> Hope this helps.
>
> Pete
>
> FennisDuck wrote:
>> I am using zz as my variable
>> what I want to do is
>> if zz is between 7 and 10 then print out a range within a sheet
>> is the print range line correct ????????
>> any assistance appreciated
>>
>> If ZZ = >1 or < =7 Then ' check value of zz
>> Range("A2:G36").PrintOut.SelectedSheets ' Print selected range
>>
>> If ZZ > 8 or < 14Then
>> Range("A2:G36").PrintOut.SelectedSheets
>


Re: using `if` a value is between - still need help plz
"Pete_UK" <pashurst[ at ]auditel.net> 11.09.2006 22:03:51
You have got the symbols for greater than and equals the wrong way
round. Also, I would suggest you use ElseIf, as follows:

If ZZ >= 1 And ZZ <=7 Then
ActiveSheet.Range("A2:G36").PrintOut
ElseIf ZZ > 7 And ZZ <=14 Then
ActiveSheet.Range("A2:G71").PrintOut
ElseIf ZZ > 14 And ZZ <=22 Then
ActiveSheet.Range("A72:G106").PrintOut
End If

Not knowing what values ZZ could take, I have changed some of the
comparisons - if ZZ is 7.5, for example, I assume you would want to
print out the middle range. I think your middle range is meant to be
A37:G71. Note that if ZZ is less than 1 or greater than 22, then you
will not get a printout.

Hope this helps.

Pete

FennisDuck wrote:
[Quoted Text]
> Sorry Pete UK
> It will only print range when zz is between 1 & 7 anything above that there
> is no print
> but it is appreciated , thank you
>
> Sub PrintList()
>
> ' PrintList Macro
>
>
>
> Sheets("w002").Select
>
> ZZ = Worksheets("w001").Range("a27").Value ' get value . this is variable
>
>
>
> If ZZ => 1 And ZZ <=7 Then ' Only hthis range will
> print when value is 1 to 7
>
> ActiveSheet.Range("A2:G36").PrintOut
>
> If ZZ => 8 And ZZ < =14 Then
>
> ActiveSheet.Range("A2:G71").PrintOut
>
> If ZZ => 15 And ZZ < =22 Then
>
> ActiveSheet.Range("a72:G106").PrintOut
>
>
>
> End If
>
> End If
>
> End If
>
>
>
> End Sub
>
>
>
> "Pete_UK" <pashurst[ at ]auditel.net> wrote in message
> news:1157977200.204775.214820[ at ]h48g2000cwc.googlegroups.com...
> > You will need to use AND and get the operators in the correct syntax:
> >
> > If zz >=1 And zz <= 7 Then
> > etc
> >
> > which means if zz is between 1 and 7 (inclusive) then do something ...
> >
> > Hope this helps.
> >
> > Pete
> >
> > FennisDuck wrote:
> >> I am using zz as my variable
> >> what I want to do is
> >> if zz is between 7 and 10 then print out a range within a sheet
> >> is the print range line correct ????????
> >> any assistance appreciated
> >>
> >> If ZZ = >1 or < =7 Then ' check value of zz
> >> Range("A2:G36").PrintOut.SelectedSheets ' Print selected range
> >>
> >> If ZZ > 8 or < 14Then
> >> Range("A2:G36").PrintOut.SelectedSheets
> >

Re: using `if` a value is between
"FennisDuck" <Fennis[ at ]Menace.AOL.com> 12.09.2006 08:37:03
thank you very much the formula worked spot on
the aim was to dump pages = to members records so I changed the start range
to A2 in all ranges and it dumps the required amount of pages

once again thank you



You have got the symbols for greater than and equals the wrong way
round. Also, I would suggest you use ElseIf, as follows:

If ZZ >= 1 And ZZ <=7 Then
ActiveSheet.Range("A2:G36").PrintOut
ElseIf ZZ > 7 And ZZ <=14 Then
ActiveSheet.Range("A2:G71").PrintOut
ElseIf ZZ > 14 And ZZ <=22 Then
ActiveSheet.Range("A72:G106").PrintOut
End If

Not knowing what values ZZ could take, I have changed some of the
comparisons - if ZZ is 7.5, for example, I assume you would want to
print out the middle range. I think your middle range is meant to be
A37:G71. Note that if ZZ is less than 1 or greater than 22, then you
will not get a printout.

Hope this helps.

Pete

FennisDuck wrote:
[Quoted Text]
> Sorry Pete UK
> It will only print range when zz is between 1 & 7 anything above that
> there
> is no print
> but it is appreciated , thank you
>
> Sub PrintList()
>
> ' PrintList Macro
>
>
>
> Sheets("w002").Select
>
> ZZ = Worksheets("w001").Range("a27").Value ' get value . this is
> variable
>
>
>
> If ZZ => 1 And ZZ <=7 Then ' Only hthis range will
> print when value is 1 to 7
>
> ActiveSheet.Range("A2:G36").PrintOut
>
> If ZZ => 8 And ZZ < =14 Then
>
> ActiveSheet.Range("A2:G71").PrintOut
>
> If ZZ => 15 And ZZ < =22 Then
>
> ActiveSheet.Range("a72:G106").PrintOut
>
>
>
> End If
>
> End If
>
> End If
>
>
>
> End Sub
>
>
>
> "Pete_UK" <pashurst[ at ]auditel.net> wrote in message
> news:1157977200.204775.214820[ at ]h48g2000cwc.googlegroups.com...
> > You will need to use AND and get the operators in the correct syntax:
> >
> > If zz >=1 And zz <= 7 Then
> > etc
> >
> > which means if zz is between 1 and 7 (inclusive) then do something ...
> >
> > Hope this helps.
> >
> > Pete
> >
> > FennisDuck wrote:
> >> I am using zz as my variable
> >> what I want to do is
> >> if zz is between 7 and 10 then print out a range within a sheet
> >> is the print range line correct ????????
> >> any assistance appreciated
> >>
> >> If ZZ = >1 or < =7 Then ' check value of zz
> >> Range("A2:G36").PrintOut.SelectedSheets ' Print selected range
> >>
> >> If ZZ > 8 or < 14Then
> >> Range("A2:G36").PrintOut.SelectedSheets
> >


Re: using `if` a value is between
"Pete_UK" <pashurst[ at ]auditel.net> 12.09.2006 08:41:42
Thanks for feeding back - I'm glad it worked for you.

Pete

FennisDuck wrote:
[Quoted Text]
> thank you very much the formula worked spot on
> the aim was to dump pages = to members records so I changed the start range
> to A2 in all ranges and it dumps the required amount of pages
>
> once again thank you
>
>
>
> You have got the symbols for greater than and equals the wrong way
> round. Also, I would suggest you use ElseIf, as follows:
>
> If ZZ >= 1 And ZZ <=7 Then
> ActiveSheet.Range("A2:G36").PrintOut
> ElseIf ZZ > 7 And ZZ <=14 Then
> ActiveSheet.Range("A2:G71").PrintOut
> ElseIf ZZ > 14 And ZZ <=22 Then
> ActiveSheet.Range("A72:G106").PrintOut
> End If
>
> Not knowing what values ZZ could take, I have changed some of the
> comparisons - if ZZ is 7.5, for example, I assume you would want to
> print out the middle range. I think your middle range is meant to be
> A37:G71. Note that if ZZ is less than 1 or greater than 22, then you
> will not get a printout.
>
> Hope this helps.
>
> Pete
>
> FennisDuck wrote:
> > Sorry Pete UK
> > It will only print range when zz is between 1 & 7 anything above that
> > there
> > is no print
> > but it is appreciated , thank you
> >
> > Sub PrintList()
> >
> > ' PrintList Macro
> >
> >
> >
> > Sheets("w002").Select
> >
> > ZZ = Worksheets("w001").Range("a27").Value ' get value . this is
> > variable
> >
> >
> >
> > If ZZ => 1 And ZZ <=7 Then ' Only hthis range will
> > print when value is 1 to 7
> >
> > ActiveSheet.Range("A2:G36").PrintOut
> >
> > If ZZ => 8 And ZZ < =14 Then
> >
> > ActiveSheet.Range("A2:G71").PrintOut
> >
> > If ZZ => 15 And ZZ < =22 Then
> >
> > ActiveSheet.Range("a72:G106").PrintOut
> >
> >
> >
> > End If
> >
> > End If
> >
> > End If
> >
> >
> >
> > End Sub
> >
> >
> >
> > "Pete_UK" <pashurst[ at ]auditel.net> wrote in message
> > news:1157977200.204775.214820[ at ]h48g2000cwc.googlegroups.com...
> > > You will need to use AND and get the operators in the correct syntax:
> > >
> > > If zz >=1 And zz <= 7 Then
> > > etc
> > >
> > > which means if zz is between 1 and 7 (inclusive) then do something ...
> > >
> > > Hope this helps.
> > >
> > > Pete
> > >
> > > FennisDuck wrote:
> > >> I am using zz as my variable
> > >> what I want to do is
> > >> if zz is between 7 and 10 then print out a range within a sheet
> > >> is the print range line correct ????????
> > >> any assistance appreciated
> > >>
> > >> If ZZ = >1 or < =7 Then ' check value of zz
> > >> Range("A2:G36").PrintOut.SelectedSheets ' Print selected range
> > >>
> > >> If ZZ > 8 or < 14Then
> > >> Range("A2:G36").PrintOut.SelectedSheets
> > >

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net