1 min readfrom Microsoft Excel | Help & Support with your Formula, Macro, and VBA problems | A Reddit Community

Moving Columns of Data in VBA Code Causes Entire Macro to Crash.

I'm working on a macro to manipulate a large data file. This macro successfully applies filters, creates tables, creates new tabs, adds cell borders, renames columns, etc. Everything works as intended and the whole thing runs in maybe 3-4 seconds.

When I add the below code to simply move some of the columns around at the beginning of the macro, the whole thing freaks out and I can't figure out why. The macro starts to run VERY slowly, data doesn't get copied/pasted correctly, borders are applied incorrectly, filters are left on....it doesn't make any sense to me.

Columns("D:D").Select

' Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove

' Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove

' Columns("Q:R").Select

' Selection.Cut

' Range("D1").Select

' ActiveSheet.Paste

' Columns("Q:R").Select

' Selection.Delete Shift:=xlToLeft

' Columns("Y:Y").Select

' Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove

' Columns("AG:AG").Select

' Selection.Cut

' Range("Y1").Select

' ActiveSheet.Paste

' Columns("X:X").Select

' Selection.Cut

' Range("AG1").Select

' ActiveSheet.Paste

' Columns("X:X").Select

' Selection.Delete Shift:=xlToLeft

' Range("AH1").Select

' ActiveCell.FormulaR1C1 = "CUC ECD"

' Application.CutCopyMode = False

Without this code, everything is perfect. With this code, the whole thing freaks out. Please help me.

submitted by /u/Marclar-Sandwich
[link] [comments]

Want to read more?

Check out the full article on the original site

View original article

Tagged with

#Excel alternatives for data analysis
#no-code spreadsheet solutions
#big data management in spreadsheets
#generative AI for data analysis
#conversational data analysis
#real-time data collaboration
#intelligent data visualization
#rows.com
#Excel compatibility
#large dataset processing
#financial modeling with spreadsheets
#VBA
#macro
#columns
#Excel
#data manipulation
#filters
#tables
#cell borders
#copy/paste