Results 1 to 6 of 6

Thread: Do until loop doesn't work with complex reference formula ?
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Jun 2018
    Posts
    46
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Do until loop doesn't work with complex reference formula ?

    So generally I am trying to make my text formula work, but as many other methods, this one doesn't work for some reason.
    Code:
    =IFERROR('K:\PLANING\Apr\[Thu, Apr 11.xlsb]Millright data'!B7+'K:\PLANING\Apr\[Thu, Apr 11_2.xlsb]Millright data'!B7,'K:\PLANING\Apr\[Thu, Apr 11.xlsb]Millright data'!B7
    This formula is text form, hence it doesn't work, until you change something within it.

    Code:
    Private Sub CommandButton1_Click()
    Dim i As Integer
    i = 97
    
    
    Do Until i > 374
        Cells(i, 3).Replace What:="=", Replacement:="="
        i = i + 1
    Loop
    End Sub
    So this code works fine for everything, but my formula. It works fine with making basic text reference formula into real one, it works fine with changing signs like =,+,- e.t.c

  2. #2
    MrExcel MVP
    Junior Admin
    Joe4's Avatar
    Join Date
    Aug 2002
    Posts
    50,717
    Post Thanks / Like
    Mentioned
    57 Post(s)
    Tagged
    11 Thread(s)

    Default Re: Do until loop doesn't work with complex reference formula ?

    No need to do all that. Just do a "Text to Columns" on that column.
    If you want to do that in VBA, just use:
    Code:
    Private Sub CommandButton1_Click()
        Columns("C:C").TextToColumns Destination:=Range("C1"), DataType:=xlDelimited, _
            TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
            Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
            :=Array(1, 1), TrailingMinusNumbers:=True
    End Sub
    It uses no loops, so will be faster/more efficient.
    Last edited by Joe4; May 2nd, 2019 at 09:32 AM.
    TIPS FOR FINDING EXCEL SOLUTIONS
    1. Use the built-in Help that comes with Excel/Access
    2. Use the Search functionality on this board
    3. A lot of VBA code can be acquired by using the Macro Recorder.

    "Give a man a fish, feed him for a day. Teach a man to fish, feed him for life!"

  3. #3
    New Member
    Join Date
    Jun 2018
    Posts
    46
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Do until loop doesn't work with complex reference formula ?

    Thank you response. It doesn't seem to work. I tried both code and text to columns button.
    Tbh, I am not well aware of text to columns, so maybe I am doing something wrong, but all it does is separate my formula

  4. #4
    MrExcel MVP
    Junior Admin
    Joe4's Avatar
    Join Date
    Aug 2002
    Posts
    50,717
    Post Thanks / Like
    Mentioned
    57 Post(s)
    Tagged
    11 Thread(s)

    Default Re: Do until loop doesn't work with complex reference formula ?

    but all it does is separate my formula
    It shouldn't, unless you are using Spaces for Delimiters or choosing Fixed Width.

    Did you try my code, exactly as I posted it?
    That uses the Tab as a delimiter. As long as your formula does not have any tabs in it, it should not separate your formula.
    TIPS FOR FINDING EXCEL SOLUTIONS
    1. Use the built-in Help that comes with Excel/Access
    2. Use the Search functionality on this board
    3. A lot of VBA code can be acquired by using the Macro Recorder.

    "Give a man a fish, feed him for a day. Teach a man to fish, feed him for life!"

  5. #5
    New Member
    Join Date
    Jun 2018
    Posts
    46
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Do until loop doesn't work with complex reference formula ?

    Yep, I tried it exactly the way it is. While it did change one experiment formula, it didn't work with mine.
    However, I indeed had Fixed chosen. Once I got rid of it, it did work.
    Thank you a lot. I have been trying to resolve this issue for weeks !

  6. #6
    MrExcel MVP
    Junior Admin
    Joe4's Avatar
    Join Date
    Aug 2002
    Posts
    50,717
    Post Thanks / Like
    Mentioned
    57 Post(s)
    Tagged
    11 Thread(s)

    Default Re: Do until loop doesn't work with complex reference formula ?

    Yep, I tried it exactly the way it is. While it did change one experiment formula, it didn't work with mine.
    However, I indeed had Fixed chosen. Once I got rid of it, it did work.
    Odd, my code specifically declares Delimited, not Fixed Width.
    Code:
    DataType:=xlDelimited
    So if you copied and pasted exactly what I had posted, I don't see how that wouldn't work.

    Regardless, I am glad you got it to work.
    TIPS FOR FINDING EXCEL SOLUTIONS
    1. Use the built-in Help that comes with Excel/Access
    2. Use the Search functionality on this board
    3. A lot of VBA code can be acquired by using the Macro Recorder.

    "Give a man a fish, feed him for a day. Teach a man to fish, feed him for life!"

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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