Results 1 to 3 of 3

If Loop Wrong Usage?

Threaded View

  1. #1
    Registered User
    Join Date
    02-23-2011
    Location
    redwood city, ca
    MS-Off Ver
    Excel 2010
    Posts
    1

    If Loop Wrong Usage?

    I'm new to VBA, and was trying to write a simple loop code to check the value of a column of cells starting from B2 to B25 in sheet1 and if the value was greater than 0 it would go sheet2 and take the values starting in A1, multiple it by 3, and place the value in A2 and so forth. This would continue until all the cells in sheet1 were reviewed. For some reason this code will execute regardless of the value of the cells in B2 through B25. Cell B3 in sheet1 could have a -1 and yet the code will still execute. Any help would be appreciated.

    Sub SimpleCal()
    '
    ' LoopSimpleCal Macro
    '
    
    '
    For i = 7 To 25
    For j = 1 To 25
    
    If Worksheets("Sheet1").Cells(i, 2).Value > 0 Then
    Worksheets("Sheet2").Cells(j, 2).Value = Workesheet("Sheet2").Cells(j,1)*3
    
    End If
    Next j
    
    Next i
    End Sub
    Last edited by rylo; 02-23-2011 at 08:02 PM. Reason: added code tags

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