+ Reply to Thread
Results 1 to 4 of 4

maths operations using "CELLS" with "IF" statement

  1. #1
    Forum Contributor
    Join Date
    02-23-2015
    Location
    united kingdom
    MS-Off Ver
    14.0.7143.5000 (32-bit)
    Posts
    124

    maths operations using "CELLS" with "IF" statement

    Hi guys,

    I am wondering if i can use something like this:

    Please Login or Register  to view this content.
    Because for now it does not do anything but compiles...


    Cheers

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: maths operations using "CELLS" with "IF" statement

    The 1st and last Cells references were not qualified with Sheets(tab1)

    Please Login or Register  to view this content.
    Or you could use something like this...
    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,885

    Re: maths operations using "CELLS" with "IF" statement

    Allow me to elaborate just a bit. Using Cells with no qualification will default, but what it defaults to depends on where this code is located. In general, it is better to qualify it as AlphaFrog has demonstrated.

    • If the code is in a Sheet module, then Cells refers to that sheet.
    • If the code is in a Module module, then Cells refers to the active worksheet.


    From your code, it is not absolutely certain where it is, or what you want Cells to refer to.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: maths operations using "CELLS" with "IF" statement

    Also test if both of these comparisons evaluate to TRUE.

    Sheets(tab1).Cells(i, 6) = Sheets("Machining").Range("j10") And Sheets(tab1).Cells(i, 12) = "As wound"

    If they are comparing strings, the comparison is case sensitive e.g; "Hello" is not equal to "hello".

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 5
    Last Post: 01-23-2014, 11:02 AM
  2. Replies: 4
    Last Post: 11-17-2013, 12:05 PM
  3. [SOLVED] How to USE """"" cells count """"" change font color
    By austin123456 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 06:14 AM
  4. [SOLVED] Data validation: allow entry into a cell if other three cells have "X", "Y" and "Z"?
    By RogerRangeRover in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-05-2013, 04:49 AM
  5. Replies: 5
    Last Post: 10-12-2010, 06:46 AM
  6. Replies: 3
    Last Post: 12-14-2006, 01:36 PM
  7. Replies: 5
    Last Post: 06-26-2006, 09:23 PM
  8. Replies: 7
    Last Post: 05-13-2006, 05:02 PM

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