+ Reply to Thread
Results 1 to 3 of 3

Code assistance Required

Hybrid View

seenfresh Code assistance Required 05-11-2007, 11:25 AM
Leith Ross Hello SeenFresh, The... 05-11-2007, 03:55 PM
seenfresh thanks 05-12-2007, 04:39 PM
  1. #1
    Registered User
    Join Date
    04-23-2007
    Location
    NYC
    Posts
    3

    Code assistance Required

    I am having problems executing the following code:

    I have the code to loop to row 6 for now to see if it works ....row 6 has the first occurance of what I need to execute... in cell D6 the value is:

    Cell D6 =(C6/1000)*Q6 and format is "currency"

    does this constitue as a formula in VB because it has no stated functions?

    I tried to delete the second AND condition and just leave the ISNUMERIC condition ...but this still does not execute?


    This is part of the second If statement that I would like to execute based on cell D6 value
    And IsNumeric(Cells(iRow, iCol).Value) And Cells(iRow, iCol).HasFormula = True Then

    Here is my Procedure!

     Sub WN100formulafill()
    
    ApplicationScreenUpdating = False
    'oCol = Net Revenue Share column
    'iCol = Billable Revenue column
    'jCol = Agency column
    Dim iRow As Long, eCol As Long
    oCol = 15
    iCol = 4
     JCol = 10
        For iRow = 1 To 6
    
       If Not IsNumeric(Cells(iRow, iCol).Value) And Not Left(Cells(iRow, iCol).Formula, 10) = "=SUBTOTAL(" _
            And IsNumeric(Cells(iRow, iCol).Value) And Cells(iRow, iCol).HasFormula = True Then
                Cells(iRow, oCol).Formula = "=" & Cells(iRow, iCol).Address & _
                    "-Sum(" & Cells(iRow, JCol).Address & "," & Cells(iRow, 14).Address & ")"
      
             
            End If
        Next iRow
    ApplicationScreenUpdating = True
    
    End Sub

    Any ideas! Would be much appreciated

    Thanks in advance,

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello SeenFresh,

    The problem is in the ANDing. You have a condition that is ANDed with the negation of itself (highlighted in red). This prevents the AND from ever being true.
    .
    f Not IsNumeric(Cells(iRow, iCol).Value) And Not Left(Cells(iRow, iCol).Formula, 10) = "=SUBTOTAL(" _
            And IsNumeric(Cells(iRow, iCol).Value) And Cells(iRow, iCol).HasFormula = True Then
    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    04-23-2007
    Location
    NYC
    Posts
    3

    thanks

    Thank you Leith, your right!

    my goal was to try and execute my statement if the cells in column I do not contain the subtotal formula and are numeric...

    I have one more question I have fixed the code as you suggested, but the code still seems to execute when cells in Column I are blank and contain text....maybe I am missinterpreting the ISNUMERIC function... I am just desiring to execute on two condition... if cells in Column I are do not contain the Subtotal formula and are numeric (or currency) style...

    Here is the code...it still execute when cells are blank and contain text...Would appreciate any further insight...Thanks a bunch!!

     Sub WN100formulafill()
    
    ApplicationScreenUpdating = False
    'oCol = Net Revenue Share column
    'iCol = Billable Revenue column
    'jCol = Agency column
    Dim iRow As Long, eCol As Long
    oCol = 15
    iCol = 9
     JCol = 10
        For iRow = 1 To 6
    
       If Not Left(Cells(iRow, iCol).Formula, 10) = "=SUBTOTAL(" _
            And IsNumeric(Cells(iRow, iCol).Value) Then
                Cells(iRow, oCol).Formula = "=" & Cells(iRow, iCol).Address & _
                    "-Sum(" & Cells(iRow, JCol).Address & "," & Cells(iRow, 14).Address & ")"
      
             
            End If
        Next iRow
    ApplicationScreenUpdating = True
    
    End Sub

+ Reply to Thread

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