rsutton1981
New Member
- Joined
- Mar 9, 2016
- Messages
- 47
- Office Version
- 365
- Platform
- Windows
Hi,
I have some code below. it works up to the line calculate cost where it just returns the value from the first if statement. Please help
I have some code below. it works up to the line calculate cost where it just returns the value from the first if statement. Please help
Code:
Sub data_sorting()
Dim Bcell As Range
Dim NextRow
Dim I As Integer
WS_Count = ActiveWorkbook.Worksheets.Count
'Jan
Sheets("Jan").Range("A2:AA10000").Clear
For Each Bcell In Sheets("Data Input").Range("Az15", Sheets("Data Input").Range("Az" & Rows.Count).End(xlUp))
If Bcell.Value = "Jan" Then
NextRow = Sheets("Jan").Range("A" & Rows.Count).End(xlUp).row + 1
Sheets("Jan").Range("A" & NextRow) = Sheets("Data Input").Range("G" & Bcell.row)
Sheets("Jan").Range("B" & NextRow) = Sheets("Data Input").Range("AB" & Bcell.row)
Sheets("Jan").Range("C" & NextRow) = Sheets("Data Input").Range("P" & Bcell.row)
'calculate paper size
If Sheets("Jan").Range("C" & NextRow) >= 0.55 Then
Sheets("Jan").Range("d" & NextRow) = "A0"
ElseIf Sheets("Jan").Range("C" & NextRow) >= 0.27 Then
Sheets("Jan").Range("d" & NextRow) = "A1"
ElseIf Sheets("Jan").Range("C" & NextRow) <= 0.26 Then
Sheets("Jan").Range("d" & NextRow) = "A2"
ElseIf Sheets("Jan").Range("C" & NextRow) <= 0.13 Then
Sheets("Jan").Range("d" & NextRow) = "A3"
End If
'calculate cost
If Sheets("Jan").Range("D" & NextRow) = "A1" & Sheets("Jan").Range("B" & NextRow) <= 30 Then
Sheets("Jan").Range("E" & NextRow) = "2.5"
ElseIf Sheets("Jan").Range("D" & NextRow) = "A1" & Sheets("Jan").Range("b" & NextRow) >= 31 Then
Sheets("Jan").Range("E" & NextRow) = "5"
ElseIf Sheets("Jan").Range("D" & NextRow) = "A1" & Sheets("Jan").Range("b" & NextRow) >= 61 Then
Sheets("Jan").Range("E" & NextRow) = "8"
ElseIf Sheets("Jan").Range("D" & NextRow) = "A0" & Sheets("Jan").Range("b" & NextRow) <= 30 Then
Sheets("Jan").Range("E" & NextRow) = "5"
ElseIf Sheets("Jan").Range("D" & NextRow) = "A0" & Sheets("Jan").Range("b" & NextRow) >= 31 Then
Sheets("Jan").Range("E" & NextRow) = "8"
ElseIf Sheets("Jan").Range("D" & NextRow) = "A0" & Sheets("Jan").Range("b" & NextRow) >= 61 Then
Sheets("Jan").Range("E" & NextRow) = "10"
ElseIf Sheets("Jan").Range("D" & NextRow) = "A2" & Sheets("Jan").Range("b" & NextRow) <= 30 Then
Sheets("Jan").Range("E" & NextRow) = "1.25"
ElseIf Sheets("Jan").Range("D" & NextRow) = "A2" & Sheets("Jan").Range("b" & NextRow) >= 31 Then
Sheets("Jan").Range("E" & NextRow) = "2"
ElseIf Sheets("Jan").Range("D" & NextRow) = "A2" & Sheets("Jan").Range("b" & NextRow) >= 61 Then
Sheets("Jan").Range("E" & NextRow) = "2.5"
ElseIf Sheets("Jan").Range("D" & NextRow) = "A3" Then
Sheets("Jan").Range("E" & NextRow) = "0.5"
End If
End If
Next Bcell
End Sub