Posts by jolivanes

    Like so?

    Does this do it?

    Code
    1. Sub Sort_Indiv_Columns()
    2. Dim i As Long, lr As Long
    3. With ActiveSheet
    4. For i = 1 To .Cells(1, .Columns.Count).End(xlToLeft).Column
    5. lr = .Cells(.Rows.Count, i).End(xlUp).Row
    6. .Range(.Cells(1, i), .Cells(lr, i)).Sort Key1:=.Cells(1, i), Order1:=xlAscending, Header:=xlYes, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
    7. Next i
    8. End With
    9. End Sub

    When in Sheet1, run this macro and have a look at what is selected.

    Code
    1. Sub AAAAA()
    2. Sheet1.Range("1:1").Select
    3. End Sub

    After that, go to Sheet2 and run this macro and see what is selected.

    Code
    1. Sub AAAAA()
    2. Sheet2.Range("G11").Select
    3. End Sub

    Is the two selections what you want to compare?

    If not, let us know what you want to do by accurately describing, not code that does not work, what you want to achieve.

    I have not downloaded your file. I try to stay away from doing that. Been unpleasantly surprised too many times.

    Have an empty Sheet2 to receive result. If not, change the Sheet2 reference to whatever it needs to be.

    Just for the heck of it, instead of having 2 macros, use a single one.

    Change references as required.

    Code
    1. Sub Maybe()
    2. Dim prntRng, i As Long
    3. prntRng = Array("A1:I20", "A1:I40") '<---- Change as required
    4. For i = LBound(prntRng) To UBound(prntRng)
    5. ActiveSheet.PageSetup.PrintArea = Range(prntRng(i)).Address
    6. ActiveSheet.PrintOut , , , , , True, , "C:\Users\cyril\Desktop\" & Range("X1").Value & i & ".PDF"
    7. Next i
    8. End Sub

    We all (well, most of us anyway) started the same way you did and guess what, we all learned as we went along.

    The way to go in my opinion is to attach a workbook with a before and after, different sheets if that suits you, and an explanation in it that explains how you arrived at the answers.

    My personal preference is to have everything in one workbook. I usually have a "data" sheet with all info and have the result in another sheet. Mind you, having it in the same sheet off to the side is possible also of course. Other people have different ideas but there are many roads leading to Rome and they all get there.

    The gentleman from Post #3 has a world of experience so stick close to what he suggest

    "The second filter is in another sheet and it's simply trying to filter out all values that aren't zero."

    Which sheet is this in your attachment?


    "Worksheets("Instructions").Range("A6").Value"

    Where is this sheet in your attachment?


    Attach a representative workbook.

    Code
    1. Sub Maybe_So()
    2. With Sheets("Sheet1").Range("A1").CurrentRegion
    3. .AutoFilter 1, Worksheets("Instructions").Range("A6")
    4. With Sheets("Sheet2").Range("A1").CurrentRegion
    5. .AutoFilter 40, "<>0"
    6. End With
    7. End With
    8. End Sub


    BTW, if your drop down list values have a leading 0 (zero) they are not numerical values but text (String).

    So "CostCenter" would not be an Integer but a String.