Consulting

Results 1 to 8 of 8

Thread: Solved: Consolidating Columns 2

  1. #1
    VBAX Tutor
    Joined
    Feb 2006
    Posts
    295
    Location

    Solved: Consolidating Columns 2

    Hi,

    In a previous post
    http://www.vbaexpress.com/forum/showthread.php?t=8528
    I received 2 solutions which works flawlessly in Excel 2002.

    I am now trying to run them in Excel 97 but am running into problems.

    Utilizing ALe's solution, i am getting a "Compile Error: Can't Assign to Array" .
    Utilizing Matt's solution, i am getting a "Run-Time Error 13:Type Mismatch".

    Any ideas as to how i can fix this to run in Excel 97?

    thanks
    zach

  2. #2
    VBAX Tutor
    Joined
    Feb 2006
    Posts
    295
    Location
    had the errors reversed

    Utilizing ALe's solution, i am getting a "Run-Time Error 13:Type Mismatch".
    Utilizing Matt's solution, i am getting a "Compile Error: Can't Assign to Array" .

  3. #3
    Knowledge Base Approver
    The King of Overkill!
    VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    Hi Zach,

    I can't say for sure about mine, as I don't have xl97 to test it on, but I'm guessing it is on the line[vba]SheetData = UsedRG.Value[/vba]I don't know if array transfers work in excel 97, but one thing you could try is changing the Dim statement for SheetData from[vba]Dim SheetData()[/vba]to just [vba]Dim SheetData[/vba]
    Perhaps xl97 doesn't like variant arrays. Could very well just be a limitation of xl97 though.

    Matt

  4. #4
    VBAX Tutor
    Joined
    Feb 2006
    Posts
    295
    Location
    hi Matt,

    that works !

    before i mark this solved, i want to see if ALe has a solution as well

    thanks
    zach

  5. #5
    Knowledge Base Approver
    The King of Overkill! VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    What line are you getting the error on for his code?

    Looking at his code, it looks like the variables "Expt" and "i" aren't dimensioned. I doubt that would cause the error, but it is possible. Try changing his Dim line to:[vba]Dim MyRange As Range, cella As Range, Expt As Long, i As Long[/vba]If that doesn't fix it, try removing the "As Range" after "cella", and adding .Cells after MyRange, like:[vba]Dim MyRange As Range, cella, Expt As Long, i As Long
    'some code
    For Each cella In MyRange.Cells[/vba]Occasionally I've received errors using a non-variant variable in a For Each statement, that could do it. If not, please explain the line the error occurs on. This always helps us debug the problem.

    Matt

  6. #6
    VBAX Tutor
    Joined
    Feb 2006
    Posts
    295
    Location
    hi Matt,
    i tried your 2 suggestions but it didn't work.
    this is the line that is highlighted:
    [VBA]
    Do While cella.Offset(0, i).Value <> 0
    [/VBA]

    thanks for looking into this
    zach

  7. #7
    Knowledge Base Approver
    The King of Overkill! VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    Hmmmm.....
    Just a guess, but maybe try[vba]Do While Len(cella.Offset(0, i).Value) > 0
    'or
    Do While Len(cella.Offset(0, i).Text) > 0[/vba]

  8. #8
    VBAX Tutor
    Joined
    Feb 2006
    Posts
    295
    Location
    Matt,

    thanks so much!

    this worked
    [VBA]
    Do While Len(cella.Offset(0, i).Value) > 0
    [/VBA]

    didn't bother trying the other method

    thanks again
    zach

Posting Permissions

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