SneakyKeys1025
SneakyKeys1025

Reputation: 33

Sorting a Column but Keeping Rows Intact - VBA

I am trying to sort a column in ascending order but keep all the rows intact with it. Unfortunately my code isn't performing that. Any advice/help on this will be greatly appreciated.

Sub Ledger()

    Dim a As Integer
    Dim x As Integer
    Dim y As Integer
    Dim z As Integer

    Application.ScreenUpdating = False
    
    a = 0
    x = 1
    y = 3
    z = 2
    
    Sheets(x).Select
    Range("A1").EntireColumn.Insert
    Range("B:B").Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlYes
    Range("A2").Select

Thanks in Advance

Upvotes: 0

Views: 272

Answers (1)

SneakyKeys1025
SneakyKeys1025

Reputation: 33

I figured out what was wrong. Needed to set the range to the entire sheet so that it covered all columns. Silly mistake.

Upvotes: 1

Related Questions