Results 1 to 8 of 8

Looping Sum, If cell begins With

Threaded View

jonn Looping Sum, If cell begins... 06-06-2007, 11:48 AM
Guest I don't know about your loop,... 06-06-2007, 03:24 PM
jonn hi what does that do? 06-07-2007, 03:33 AM
mikerickson If InStr(CStr(ws1.Cells(i,... 06-07-2007, 03:43 AM
jonn hi, can you explain that... 06-07-2007, 04:41 AM
  1. #1
    Forum Contributor
    Join Date
    11-17-2006
    Posts
    152

    Looping Sum, If cell begins With

    Hi,

    my loop is not working and i can't figure out why?

    Also how do i get the macro to find cells that begin with that number and do not equal it?

    Thanks,

    Sub NomCalc()
    Dim i As Integer
    Dim ws1 As Worksheet
    Dim c As Integer
    Dim GVal As Long
    Set ws1 = Sheets("Sheet1")
    
    GVal = Sheets("P & L Major Headings").Range("B8").Value
    
    c = 23 ' Period 1
    
    If Sheets("P & L Major Headings").Range("B4") > 1.01 Then
        c = c + Sheets("P & L Major Headings").Range("B4") - 1
    Else
    End If
    
    For i = 3 To 5000
    
    If ws1.Cells(i, A) = "0124" Then 'can this search for cells that begin with this number?
        GVal = Sheets("P & L Major Headings").Range("B8").Value
        GVal = GVal + Cells(c, i).Value
    Else
    Exit Sub
    End If
    
    Next i
    
    Sheets("P & L Major Headings").Range("B8").Value = GVal
    
    End Sub
    Last edited by jonn; 06-06-2007 at 11:52 AM.

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