+ Reply to Thread
Results 1 to 2 of 2

Code problem

  1. #1
    Patrick Simonds
    Guest

    Code problem

    On my spreadsheet C3 contains a formula which returns the number 1 and cell
    W1 value is 1, in this case the code should skip to Continue1: and not sort
    the cells, but it is not. Can anyone tell me why?

    If Range("C3").Value = Range("W1").Value Then

    GoTo Continue1

    End If

    If Range("C3").Value > "" Then

    Range("A4:C8").Select
    Selection.Sort Key1:=Range("A4"), Order1:=xlAscending, Header:=xlGuess,
    _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    DataOption1:=xlSortNormal

    End If

    Continue1:



  2. #2
    Bob Phillips
    Guest

    Re: Code problem

    Are you sure that C3 is exactly 1, it doesn't have some very small
    fractional part. Try increasing the decimal places to see.

    If so, and dealing with integers, you could use

    If Int(Range("C3").Value) = Int(Range("W1").Value) Then

    --

    HTH

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


    "Patrick Simonds" <[email protected]> wrote in message
    news:[email protected]...
    > On my spreadsheet C3 contains a formula which returns the number 1 and

    cell
    > W1 value is 1, in this case the code should skip to Continue1: and not

    sort
    > the cells, but it is not. Can anyone tell me why?
    >
    > If Range("C3").Value = Range("W1").Value Then
    >
    > GoTo Continue1
    >
    > End If
    >
    > If Range("C3").Value > "" Then
    >
    > Range("A4:C8").Select
    > Selection.Sort Key1:=Range("A4"), Order1:=xlAscending,

    Header:=xlGuess,
    > _
    > OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    > DataOption1:=xlSortNormal
    >
    > End If
    >
    > Continue1:
    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1