direktoren
May 29th, 2006, 01:57 AM
Hi
A new problem has arisen in my macro (surprise!)...
What I have is;
Case "Credit"
gSheet.Rows(j).EntireRow.Copy tSheet.Rows(j)
For l = 5 To 350
Select Case gSheet.Cells(l, 1).Value
Case "W3900"
For m = l To gSheet.Cells(l, 2).End(xlDown).Row
Select Case gSheet.Cells(m, 2).Value
Case gSheet.Cells(j, 2).Value
gSheet.Activate
gSheet.Range(Cells(m, 3), Cells(m, 3).End(xlToRight)).Copy
tSheet.Activate
tSheet.Range(Cells(j, 3), Cells(j, 3).End(xlToRight)).PasteSpecial Paste:=xlValues, operation:=xlAdd
Application.CutCopyMode = False
End Select
Next m
Case "Z3988"
For m = l To gSheet.Cells(l, 2).End(xlDown).Row
Select Case gSheet.Cells(m, 2).Value
Case gSheet.Cells(j, 2).Value
gSheet.Activate
gSheet.Range(Cells(m, 3), Cells(m, 3).End(xlToRight)).Copy
tSheet.Activate
tSheet.Range(Cells(j, 3), Cells(j, 3).End(xlToRight)).PasteSpecial Paste:=xlValues, operation:=xlAdd
Application.CutCopyMode = False
End Select
Next m
Case "N3394"
For m = l To gSheet.Cells(l, 2).End(xlDown).Row
Select Case gSheet.Cells(m, 2).Value
Case gSheet.Cells(j, 2).Value
gSheet.Activate
gSheet.Range(Cells(m, 3), Cells(m, 3).End(xlToRight)).Copy
tSheet.Activate
tSheet.Range(Cells(j, 3), Cells(j, 3).End(xlToRight)).PasteSpecial Paste:=xlValues, operation:=xlSubtract
Application.CutCopyMode = False
End Select
Next m
Case "3472Hen"
For m = l To gSheet.Cells(l, 2).End(xlDown).Row
Select Case gSheet.Cells(m, 2).Value
Case gSheet.Cells(j, 2).Value
gSheet.Activate
gSheet.Range(Cells(m, 3), Cells(m, 3).End(xlToRight)).Copy
tSheet.Activate
tSheet.Range(Cells(j, 3), Cells(j, 3).End(xlToRight)).PasteSpecial Paste:=xlValues, operation:=xlSubtract
Application.CutCopyMode = False
End Select
Next m
End Select
Next l
This worked fine for me for a while, until I discovered a flaw! The nested cases can only perform their operations if the initial case is positive - this is however not always the case.
Can I in any way bypass this, so the nested cells will perform their operations in the same destination as they would have if the initial case had a match?
regards nick
A new problem has arisen in my macro (surprise!)...
What I have is;
Case "Credit"
gSheet.Rows(j).EntireRow.Copy tSheet.Rows(j)
For l = 5 To 350
Select Case gSheet.Cells(l, 1).Value
Case "W3900"
For m = l To gSheet.Cells(l, 2).End(xlDown).Row
Select Case gSheet.Cells(m, 2).Value
Case gSheet.Cells(j, 2).Value
gSheet.Activate
gSheet.Range(Cells(m, 3), Cells(m, 3).End(xlToRight)).Copy
tSheet.Activate
tSheet.Range(Cells(j, 3), Cells(j, 3).End(xlToRight)).PasteSpecial Paste:=xlValues, operation:=xlAdd
Application.CutCopyMode = False
End Select
Next m
Case "Z3988"
For m = l To gSheet.Cells(l, 2).End(xlDown).Row
Select Case gSheet.Cells(m, 2).Value
Case gSheet.Cells(j, 2).Value
gSheet.Activate
gSheet.Range(Cells(m, 3), Cells(m, 3).End(xlToRight)).Copy
tSheet.Activate
tSheet.Range(Cells(j, 3), Cells(j, 3).End(xlToRight)).PasteSpecial Paste:=xlValues, operation:=xlAdd
Application.CutCopyMode = False
End Select
Next m
Case "N3394"
For m = l To gSheet.Cells(l, 2).End(xlDown).Row
Select Case gSheet.Cells(m, 2).Value
Case gSheet.Cells(j, 2).Value
gSheet.Activate
gSheet.Range(Cells(m, 3), Cells(m, 3).End(xlToRight)).Copy
tSheet.Activate
tSheet.Range(Cells(j, 3), Cells(j, 3).End(xlToRight)).PasteSpecial Paste:=xlValues, operation:=xlSubtract
Application.CutCopyMode = False
End Select
Next m
Case "3472Hen"
For m = l To gSheet.Cells(l, 2).End(xlDown).Row
Select Case gSheet.Cells(m, 2).Value
Case gSheet.Cells(j, 2).Value
gSheet.Activate
gSheet.Range(Cells(m, 3), Cells(m, 3).End(xlToRight)).Copy
tSheet.Activate
tSheet.Range(Cells(j, 3), Cells(j, 3).End(xlToRight)).PasteSpecial Paste:=xlValues, operation:=xlSubtract
Application.CutCopyMode = False
End Select
Next m
End Select
Next l
This worked fine for me for a while, until I discovered a flaw! The nested cases can only perform their operations if the initial case is positive - this is however not always the case.
Can I in any way bypass this, so the nested cells will perform their operations in the same destination as they would have if the initial case had a match?
regards nick