Results 1 to 2 of 2

Changing variable based on a count

Threaded View

  1. #1
    Registered User
    Join Date
    10-10-2014
    Location
    Ireland
    MS-Off Ver
    2013
    Posts
    37

    Changing variable based on a count

    Hi,

    In the code below i am looping through a table finding the rows with particular code (product code) and performing math on another column on that row (units) and adding it to another sheet. The problem i am having is i want the variable 'e20' to be the multiplier 'e202' when a certain number in this case greater than 250 is met. The code below attempts that however if i break this threshold of 250 in the middle of a calculation it does not register that say half of the calculation needs to be at 'e20' and the other at 'e202'. Any advice would be great.

    Thanks,
    SPM

                
    
    Sub Check_Sheet()
    
    Dim e20 As Integer
    Dim e202 As Integer
    
    e20 = 10
    e202 = 20
    
    For Row = 1 To 100
    For Col = 1 To 20
    
    If ThisWorkbook.Sheets("Sheet1").Cells(Row, Col).Value = "SEPE1E05X041" Then
                
    If ThisWorkbook.Sheets("Sheet2").Cells(16, 3).Value = 0 Then
                        
    ThisWorkbook.Sheets("Sheet2").Cells(16, 4) = ThisWorkbook.Sheets("Sheet2").Cells(16, 4).Value + ThisWorkbook.Sheets("Sheet1").Cells(Row, 13).Value * e20
    ThisWorkbook.Sheets("Sheet2").Cells(16, 3) = ThisWorkbook.Sheets("Sheet2").Cells(16, 3).Value + ThisWorkbook.Sheets("Sheet1").Cells(Row, 16).Value
                    
    ElseIf ThisWorkbook.Sheets("Sheet2").Cells(16, 3).Value > 250 Then
                        
    ThisWorkbook.Sheets("Sheet2").Cells(16, 4) = ThisWorkbook.Sheets("Sheet2").Cells(16, 4).Value + ThisWorkbook.Sheets("Sheet1").Cells(Row, 13).Value * e202
    ThisWorkbook.Sheets("Sheet2").Cells(16, 3) = ThisWorkbook.Sheets("Sheet2").Cells(16, 3).Value + ThisWorkbook.Sheets("Sheet1").Cells(Row, 16).Value
    
                    End If
                
                End If
                
            Next
        Next
    
    End Sub
    Last edited by silkpantsman; 10-06-2015 at 05:37 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 0
    Last Post: 04-08-2015, 04:40 PM
  2. Need formula to count score based on criteria (0/1 variable, time series)
    By wintheranders in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-25-2015, 04:57 AM
  3. [SOLVED] COUNT Function Based on a variable.
    By dwilkinson12 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-19-2014, 02:13 AM
  4. Get count of items based on 4 variable conditions
    By m2som in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 12-18-2013, 01:04 AM
  5. [SOLVED] Change range in formula based on changing row count
    By razz0807 in forum Excel General
    Replies: 6
    Last Post: 04-18-2012, 09:51 AM
  6. Changing cell color based on count
    By mossman65 in forum Excel General
    Replies: 1
    Last Post: 01-28-2011, 09:37 PM
  7. VBA function with changing variable count
    By JordanGoodchild in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-09-2010, 07:07 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