D
derekc
i posted this before but i think it was way comfusing.
i have a spreadsheet we download once a week. i have code written to d
what i want so far. it basically subtracts how many parts we owe dif
companies from what we have on hand. i have it to subtract until i
hits a negative number , then highlight the last date we ca
ship.(written by pikus) what i have been trying to do, and failing a
it since then, is have the remainder left over to show in the firs
emtpy cell at the end of the row, and highlight it.
ex:
the on hand number starts in g4, then it goes down the row subtractin
until it hits a neg number. then the last positive number used needs t
be placed at the first empty cell at the end of that row. the
highlighted.
if anything of this is possible i appreciate it, here is the code as i
is now.
Private Sub launchbutton_1_Click()
lastRow = Worksheets("First Sheet").UsedRange.Row - 1
Worksheets("First Sheet").UsedRange.Rows.Count
lastCol = Worksheets("First Sheet").UsedRange.Column - 1
Worksheets("First Sheet").UsedRange.Columns.Count
With Worksheets("First Sheet")
For x = 2 To lastRow
On Error GoTo Skip
y = 7
runTot = 0
parts = .Cells(x, 7).Value
Do Until y = lastCol _
Or runTot > parts
y = y + 1
runTot = runTot + .Cells(x, y).Value
Loop
If runTot > parts Then
For z = 8 To y - 1
.Cells(x, z).Interior.ColorIndex = 6
Next z
ElseIf y = lastCol Then
For z = 8 To y
If .Cells(x, z).Value <> "" Then
.Cells(x, z).Interior.ColorIndex = 6
End If
Next z
End If
Skip:
Next x
End With
End Sub
thank
i have a spreadsheet we download once a week. i have code written to d
what i want so far. it basically subtracts how many parts we owe dif
companies from what we have on hand. i have it to subtract until i
hits a negative number , then highlight the last date we ca
ship.(written by pikus) what i have been trying to do, and failing a
it since then, is have the remainder left over to show in the firs
emtpy cell at the end of the row, and highlight it.
ex:
the on hand number starts in g4, then it goes down the row subtractin
until it hits a neg number. then the last positive number used needs t
be placed at the first empty cell at the end of that row. the
highlighted.
if anything of this is possible i appreciate it, here is the code as i
is now.
Private Sub launchbutton_1_Click()
lastRow = Worksheets("First Sheet").UsedRange.Row - 1
Worksheets("First Sheet").UsedRange.Rows.Count
lastCol = Worksheets("First Sheet").UsedRange.Column - 1
Worksheets("First Sheet").UsedRange.Columns.Count
With Worksheets("First Sheet")
For x = 2 To lastRow
On Error GoTo Skip
y = 7
runTot = 0
parts = .Cells(x, 7).Value
Do Until y = lastCol _
Or runTot > parts
y = y + 1
runTot = runTot + .Cells(x, y).Value
Loop
If runTot > parts Then
For z = 8 To y - 1
.Cells(x, z).Interior.ColorIndex = 6
Next z
ElseIf y = lastCol Then
For z = 8 To y
If .Cells(x, z).Value <> "" Then
.Cells(x, z).Interior.ColorIndex = 6
End If
Next z
End If
Skip:
Next x
End With
End Sub
thank