Results 1 to 3 of 3

Thread: if statement

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2003
    Posts
    1

    if statement

    I am new to this and would appreciate some help.

    Say range c30 on sheet 1 value = 10
    range b1 on sheet 1 value = 10
    range c45 on sheet 1 value = 10000

    I am trying to write the following statement

    if Sheets("sheet1").range("c30").value = Sheets("sheet1").range("c30").value then

    sheets("data").range("b9").value = sheets("sheet1").range("c45").value
    else sheets("data").range("b9").value = 0
    end if

    It is not working. please help

  2. #2
    Frenzied Member Spajeoly's Avatar
    Join Date
    Mar 2003
    Location
    Utah
    Posts
    1,068
    Ok, looks like you might be reffering to the cells wrong and the Else you have should be ElseIf...

    VB Code:
    1. If Sheet1.Range("$C$30").Value = Sheet1.Range("$C$30").Value Then
    2.     Sheet2.Range("$B$9").Value = Sheet1.Range("$C4$5").Value
    3. Else
    4.     Sheet2.Range("$B$9").Value = 0
    5. End If
    Though the purpose of this is beyond me, you are checking to see if the value of cell C-30 is its self, which will always be true so it will always copy its self to B-9 on whatever page.

  3. #3
    Fanatic Member WorkHorse's Avatar
    Join Date
    Jul 2002
    Location
    Where you live.
    Posts
    591
    Not sure what you are trying to do. Maybe this:

    VB Code:
    1. If Sheets("Sheet1").Range("C30").Value = Sheets("Sheet1").Range("B1").Value Then
    2.     Sheets("Data").Range("B9").Value = Sheets("Sheet1").Range("C45").Value
    3. Else
    4.     Sheets("Data").Range("B9").Value = 0
    5. End If

Posting Permissions

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



Click Here to Expand Forum to Full Width