PDA

View Full Version : errors on Macro code for consolidation



Aziz_SA
11-29-2022, 10:42 AM
Hi !

I hope you are doing great !

I'm a beginner in the VBA programming , and while I'm trying use the following macro to consolidate data, i face some errors.

if any one kindly can check the following for me and guide me if there are any errors to be resolved , this would be really highly appreciated!!

thank you in advance!! :yes




consolidate Macro
ActiveCell.Offset(-12, -4).Range("A1").Select
Selection.CurrentRegion.Select
Selection.Copy
Sheets("Sheet1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(0, 3).Columns("A:D").EntireColumn.Select
Application.CutCopyMode = False
Selection.Copy
ActiveCell.Offset(0, -2).Range("A1").Select
ActiveSheet.PasteSpecial Format:=3, Link:=1, DisplayAsIcon:=False, _
IconFileName:=False
ActiveCell.Offset(0, 4).Columns("A:F").EntireColumn.Select
Selection.Delete Shift:=xlToLeft
ActiveCell.Offset(0, -5).Range("A1").Select
End Sub

Grade4.2
12-09-2022, 01:44 AM
Yes, there are a few errors in the code. The End Sub statement is missing at the end of the macro, and the Range("A1") statements are not part of the Offset method, so they need to be removed. Here is the fixed code:


Sub consolidateMacro()
ActiveCell.Offset(-12, -4).Select
Selection.CurrentRegion.Select
Selection.Copy
Sheets("Sheet1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(0, 3).Columns("A:D").EntireColumn.Select
Application.CutCopyMode = False
Selection.Copy
ActiveCell.Offset(0, -2).Select
ActiveSheet.PasteSpecial Format:=3, Link:=1, DisplayAsIcon:=False, _
IconFileName:=False
ActiveCell.Offset(0, 4).Columns("A:F").EntireColumn.Select
Selection.Delete Shift:=xlToLeft
ActiveCell.Offset(0, -5).Select
End Sub