Macros are changing functionality

Mattfrisbie

New Member
Joined
Mar 16, 2011
Messages
1
I am using a Macro to separate characters from a string in a cell using text to columns as shown below.

Sub Separate()
'
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("B1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=True, Comma:=False, Space:=False, Other:=True, OtherChar:= _
"_", FieldInfo:=Array(Array(1, 9), Array(2, 9), Array(3, 9), Array(4, 9), Array(5, 9), _
Array(6, 1), Array(7, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1) _
, Array(13, 1), Array(14, 1), Array(15, 1)), TrailingMinusNumbers:=True
Range("A1").Select
End Sub


No problems, works great. I noticed excel was trying to anticipate this action and everytime I copy from a .CSV file it tried to separate into columns. I found a way to stop that using the macro below:

Sub CorrectCSVImport()
On Error Resume Next
If IsEmpty(Range("A1")) Then Range("A1") = "XYZZY"
Range("A1").TextToColumns Destination:=Range("A1"), _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, _
Tab:=False, _
Semicolon:=False, _
Comma:=False, _
Space:=False, _
Other:=False, _
OtherChar:=""
If Range("A1") = "XYZZY" Then Range("A1") = ""
If Err.Number <> 0 Then MsgBox Err.Description

End Sub

Now when I copy down formulas (drag down from lower right of cell) the formulas give me an incorrect value. If I double click on that cell that was dragged down then press enter the formula works. Mysterious!

Is there a macro that can set my sheet back to normal or a setting that tells excel not to try and help? I'm using Excel 2010.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Just a shot in the dark. If you press the F9 key, do your copied formulas update?

If yes, then somehow your workbook Calculation Mode option got switched to Manual Calculation. I don't see how that could have happened from your macro code though.

You can reset it back to automatic calculation mode under the Excel Options menu or run a macro like this...
Code:
Sub Reset_AutoCalc()
Application.Calculation = xlAutomatic
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,901
Members
452,948
Latest member
Dupuhini

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