0

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

1
  • 2
    It looks like you are explicitly only sorting column B: Range("B:B").Sort Commented Nov 15, 2022 at 15:07

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.