Results 1 to 6 of 6

Thread: [RESOLVED]Tricky Excel?

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    96

    Resolved [RESOLVED]Tricky Excel?

    Hi

    A new problem has arisen in my macro (surprise!)...

    What I have is;

    VB Code:
    1. Case "Credit"
    2.           gSheet.Rows(j).EntireRow.Copy tSheet.Rows(j)
    3.           For l = 5 To 350
    4.           Select Case gSheet.Cells(l, 1).Value
    5.           Case "W3900"
    6.             For m = l To gSheet.Cells(l, 2).End(xlDown).Row
    7.             Select Case gSheet.Cells(m, 2).Value
    8.             Case gSheet.Cells(j, 2).Value
    9.               gSheet.Activate
    10.               gSheet.Range(Cells(m, 3), Cells(m, 3).End(xlToRight)).Copy
    11.               tSheet.Activate
    12.               tSheet.Range(Cells(j, 3), Cells(j, 3).End(xlToRight)).PasteSpecial Paste:=xlValues, operation:=xlAdd
    13.               Application.CutCopyMode = False
    14.             End Select
    15.             Next m
    16.           Case "Z3988"
    17.             For m = l To gSheet.Cells(l, 2).End(xlDown).Row
    18.             Select Case gSheet.Cells(m, 2).Value
    19.             Case gSheet.Cells(j, 2).Value
    20.               gSheet.Activate
    21.               gSheet.Range(Cells(m, 3), Cells(m, 3).End(xlToRight)).Copy
    22.               tSheet.Activate
    23.               tSheet.Range(Cells(j, 3), Cells(j, 3).End(xlToRight)).PasteSpecial Paste:=xlValues, operation:=xlAdd
    24.               Application.CutCopyMode = False
    25.             End Select
    26.             Next m
    27.           Case "N3394"
    28.             For m = l To gSheet.Cells(l, 2).End(xlDown).Row
    29.             Select Case gSheet.Cells(m, 2).Value
    30.             Case gSheet.Cells(j, 2).Value
    31.               gSheet.Activate
    32.               gSheet.Range(Cells(m, 3), Cells(m, 3).End(xlToRight)).Copy
    33.               tSheet.Activate
    34.               tSheet.Range(Cells(j, 3), Cells(j, 3).End(xlToRight)).PasteSpecial Paste:=xlValues, operation:=xlSubtract
    35.               Application.CutCopyMode = False
    36.             End Select
    37.             Next m
    38.           Case "3472Hen"
    39.             For m = l To gSheet.Cells(l, 2).End(xlDown).Row
    40.             Select Case gSheet.Cells(m, 2).Value
    41.             Case gSheet.Cells(j, 2).Value
    42.               gSheet.Activate
    43.               gSheet.Range(Cells(m, 3), Cells(m, 3).End(xlToRight)).Copy
    44.               tSheet.Activate
    45.               tSheet.Range(Cells(j, 3), Cells(j, 3).End(xlToRight)).PasteSpecial Paste:=xlValues, operation:=xlSubtract
    46.               Application.CutCopyMode = False
    47.             End Select
    48.             Next m
    49.           End Select
    50.           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
    Last edited by direktoren; May 30th, 2006 at 05:38 AM. Reason: RESOLVED

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width