Statement not working correctly

shumba

Board Regular
Joined
Oct 5, 2010
Messages
168
Hi,

The first statement (underlined) in the Sub Procedure below is meant to test whether or not the value in the current selection is greater than 50000. When the procedure is run it is selecting values of less than 50000 as well as values greater than 50000.

Please will someone show me where I am going wrong.

Code:
Sub Analyse()
      Sheets("Market Interface").Select
      Range("p4").Select
      Do Until IsEmpty(ActiveCell)
      [U]If Selection.Value > 50000 And[/U] _
      Selection.Offset(0, -13).Value > Selection.Offset(0, 11).Value And _
      Selection.Offset(0, 23).Value > 0 And _
      Selection.Offset(0, -3).Value = Selection.Offset(0, -13).Value And _
      Selection.Offset(0, -13).Value < Selection.Offset(0, 8).Value And _
      Selection.Offset(0, -10).Value > Selection.Offset(0, 8).Value Or _
      Selection.Offset(0, -6).Value > Selection.Offset(0, 8).Value Then _
      Selection.Offset(0, -2).Copy Sheets("User Interface").Range("a:a").Cells(Rows.Count).End(xlUp).Offset(1, 0)
      Selection.Offset(1, 0).Select
      Loop
  End Sub
Thanks.

Rob.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
I think the Or part of that statement is probably being met even when your selection is < 50000.
 
Upvote 0

Forum statistics

Threads
1,224,596
Messages
6,179,807
Members
452,944
Latest member
2558216095

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top