Consulting

Results 1 to 3 of 3

Thread: Solved: how to define the cells?

  1. #1

    Solved: how to define the cells?

    I am trying the following code under sheet_activate event but it gives error.
    For i = 1 To 100
    If Cells(12, i).Value <> "" And Cells(13, i).Value <> "" Then

    Cells(14, i) = Cells(12, i).Value - 25 * Cells(13, i).Value
    End If
    Next

    the error shows is application-defined or object-defined error. it seems the problem is with i at cells( , i) and we cannot have variable in paranteses. How to solve this problem and how to write other way?

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    works fine for me....I did put your operation in parenthesis so the subtraction is done before the multiplication:
    [VBA]Cells(14, i) = (Cells(12, i).Value - 25) * Cells(13, i).Value[/VBA]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Do you have text in any of the cells?

Posting Permissions

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