Consulting

Results 1 to 2 of 2

Thread: errors on Macro code for consolidation

  1. #1
    VBAX Newbie
    Joined
    Nov 2022
    Posts
    1
    Location

    errors on Macro code for consolidation

    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!!



    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
    Last edited by Aussiebear; 11-29-2022 at 11:50 PM. Reason: Added code tags to supplied code

  2. #2
    VBAX Regular
    Joined
    May 2018
    Location
    Sydney
    Posts
    57
    Location
    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
    Last edited by Aussiebear; 12-09-2022 at 03:33 AM. Reason: Added code tags to supplied code
    If you only ever do what you can , you'll only ever be what you are.

Posting Permissions

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