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

szakharov7723

Board Regular
Joined
Jun 22, 2018
Messages
85
Office Version
  1. 2019
Platform
  1. Windows
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
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
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:
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0
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 !
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,213,531
Messages
6,114,167
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top