Excel VBA- Finding the last column with data












37















I've found this method for finding the last data containing row in a sheet:



ws.Range("A65536").End(xlUp).row


Is there a similar method for finding the last data containing column in a sheet?



Thanks.










share|improve this question




















  • 2





    This might not work for Excel 2007+ workbook, which may have over a million rows. You might want to use ws.UsedRange instead.

    – ikh
    Aug 13 '12 at 1:24











  • Ah, thanks for that. I didn't know.

    – Neat Machine
    Aug 13 '12 at 2:14






  • 3





    @ikh, its prob better to use ws.Cells(Rows.Count, "A").End(xlUp).row

    – Reafidy
    Aug 13 '12 at 2:16








  • 2





    possible duplicate of Copy last column with data on specified row to the next blank column

    – Siddharth Rout
    Aug 13 '12 at 3:43
















37















I've found this method for finding the last data containing row in a sheet:



ws.Range("A65536").End(xlUp).row


Is there a similar method for finding the last data containing column in a sheet?



Thanks.










share|improve this question




















  • 2





    This might not work for Excel 2007+ workbook, which may have over a million rows. You might want to use ws.UsedRange instead.

    – ikh
    Aug 13 '12 at 1:24











  • Ah, thanks for that. I didn't know.

    – Neat Machine
    Aug 13 '12 at 2:14






  • 3





    @ikh, its prob better to use ws.Cells(Rows.Count, "A").End(xlUp).row

    – Reafidy
    Aug 13 '12 at 2:16








  • 2





    possible duplicate of Copy last column with data on specified row to the next blank column

    – Siddharth Rout
    Aug 13 '12 at 3:43














37












37








37


22






I've found this method for finding the last data containing row in a sheet:



ws.Range("A65536").End(xlUp).row


Is there a similar method for finding the last data containing column in a sheet?



Thanks.










share|improve this question
















I've found this method for finding the last data containing row in a sheet:



ws.Range("A65536").End(xlUp).row


Is there a similar method for finding the last data containing column in a sheet?



Thanks.







excel excel-vba vba






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 9 '18 at 18:41









Community

11




11










asked Aug 13 '12 at 0:33









Neat MachineNeat Machine

2654718




2654718








  • 2





    This might not work for Excel 2007+ workbook, which may have over a million rows. You might want to use ws.UsedRange instead.

    – ikh
    Aug 13 '12 at 1:24











  • Ah, thanks for that. I didn't know.

    – Neat Machine
    Aug 13 '12 at 2:14






  • 3





    @ikh, its prob better to use ws.Cells(Rows.Count, "A").End(xlUp).row

    – Reafidy
    Aug 13 '12 at 2:16








  • 2





    possible duplicate of Copy last column with data on specified row to the next blank column

    – Siddharth Rout
    Aug 13 '12 at 3:43














  • 2





    This might not work for Excel 2007+ workbook, which may have over a million rows. You might want to use ws.UsedRange instead.

    – ikh
    Aug 13 '12 at 1:24











  • Ah, thanks for that. I didn't know.

    – Neat Machine
    Aug 13 '12 at 2:14






  • 3





    @ikh, its prob better to use ws.Cells(Rows.Count, "A").End(xlUp).row

    – Reafidy
    Aug 13 '12 at 2:16








  • 2





    possible duplicate of Copy last column with data on specified row to the next blank column

    – Siddharth Rout
    Aug 13 '12 at 3:43








2




2





This might not work for Excel 2007+ workbook, which may have over a million rows. You might want to use ws.UsedRange instead.

– ikh
Aug 13 '12 at 1:24





This might not work for Excel 2007+ workbook, which may have over a million rows. You might want to use ws.UsedRange instead.

– ikh
Aug 13 '12 at 1:24













Ah, thanks for that. I didn't know.

– Neat Machine
Aug 13 '12 at 2:14





Ah, thanks for that. I didn't know.

– Neat Machine
Aug 13 '12 at 2:14




3




3





@ikh, its prob better to use ws.Cells(Rows.Count, "A").End(xlUp).row

– Reafidy
Aug 13 '12 at 2:16







@ikh, its prob better to use ws.Cells(Rows.Count, "A").End(xlUp).row

– Reafidy
Aug 13 '12 at 2:16






2




2





possible duplicate of Copy last column with data on specified row to the next blank column

– Siddharth Rout
Aug 13 '12 at 3:43





possible duplicate of Copy last column with data on specified row to the next blank column

– Siddharth Rout
Aug 13 '12 at 3:43












5 Answers
5






active

oldest

votes


















75














Lots of ways to do this. The most reliable is find.



Dim rLastCell As Range

Set rLastCell = ws.Cells.Find(What:="*", After:=ws.Cells(1, 1), LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, MatchCase:=False)

MsgBox ("The last used column is: " & rLastCell.Column)


If you want to find the last column used in a particular row you can use:



Dim lColumn As Long

lColumn = ws.Cells(1, Columns.Count).End(xlToLeft).Column


Using used range (less reliable):



Dim lColumn As Long

lColumn = ws.UsedRange.Columns.Count


Using used range wont work if you have no data in column A. See here for another issue with used range:



See Here regarding resetting used range.






share|improve this answer


























  • Perfect. Thank you.

    – Neat Machine
    Aug 13 '12 at 2:14













  • You welcome, more info here

    – Reafidy
    Aug 13 '12 at 2:15






  • 1





    + 1 readfidy :) A suggestion though... Always use Application.CountA with .Find to avoid errors. See this stackoverflow.com/questions/11883256/…

    – Siddharth Rout
    Aug 13 '12 at 3:39






  • 1





    Thanks @Sidd, you will find exactly that suggestion and additional info in the link I provided to Ozgrid in my comment above.

    – Reafidy
    Aug 13 '12 at 4:15











  • True :) I should have visited that link :)

    – Siddharth Rout
    Aug 13 '12 at 4:17



















12














I know this is old, but I've tested this in many ways and it hasn't let me down yet, unless someone can tell me otherwise.



Row number



Row = ws.Cells.Find(What:="*", After:=[A1] , SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row


Column Letter



ColumnLetter = Split(ws.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Cells.Address(1, 0), "$")(0)


Column Number



ColumnNumber = ws.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column





share|improve this answer































    2














    Try using the code after you active the sheet:



    Dim J as integer
    J = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row


    If you use Cells.SpecialCells(xlCellTypeLastCell).Row only, the problem will be that the xlCellTypeLastCell information will not be updated unless one do a "Save file" action. But use UsedRange will always update the information in realtime.






    share|improve this answer

































      1














      I think we can modify the UsedRange code from @Readify's answer above to get the last used column even if the starting columns are blank or not.



      So this lColumn = ws.UsedRange.Columns.Count modified to



      this lColumn = ws.UsedRange.Column + ws.UsedRange.Columns.Count - 1 will give reliable results always



      enter image description here



      ?Sheet1.UsedRange.Column + Sheet1.UsedRange.Columns.Count - 1


      Above line Yields 9 in the immediate window.






      share|improve this answer

































        1














        Here's something which might be useful. Selecting the entire column based on a row containing data, in this case i am using 5th row:



        Dim lColumn As Long

        lColumn = ActiveSheet.Cells(5, Columns.Count).End(xlToLeft).Column
        MsgBox ("The last used column is: " & lColumn)





        share|improve this answer


























        • What makes your answer different then the accepted answer, besides being shorter? Also please avoid the use of the Select statement. That is really bad practice. See stackoverflow.com/questions/10714251/…

          – Luuklag
          Jun 28 '18 at 10:14











        • it's short and simple and that's the value added. thanks for the tip on the Select statement. I will have a look. Cheers

          – dapaz
          Jun 29 '18 at 7:50










        protected by Community Oct 23 '17 at 14:26



        Thank you for your interest in this question.
        Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



        Would you like to answer one of these unanswered questions instead?














        5 Answers
        5






        active

        oldest

        votes








        5 Answers
        5






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        75














        Lots of ways to do this. The most reliable is find.



        Dim rLastCell As Range

        Set rLastCell = ws.Cells.Find(What:="*", After:=ws.Cells(1, 1), LookIn:=xlFormulas, LookAt:= _
        xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, MatchCase:=False)

        MsgBox ("The last used column is: " & rLastCell.Column)


        If you want to find the last column used in a particular row you can use:



        Dim lColumn As Long

        lColumn = ws.Cells(1, Columns.Count).End(xlToLeft).Column


        Using used range (less reliable):



        Dim lColumn As Long

        lColumn = ws.UsedRange.Columns.Count


        Using used range wont work if you have no data in column A. See here for another issue with used range:



        See Here regarding resetting used range.






        share|improve this answer


























        • Perfect. Thank you.

          – Neat Machine
          Aug 13 '12 at 2:14













        • You welcome, more info here

          – Reafidy
          Aug 13 '12 at 2:15






        • 1





          + 1 readfidy :) A suggestion though... Always use Application.CountA with .Find to avoid errors. See this stackoverflow.com/questions/11883256/…

          – Siddharth Rout
          Aug 13 '12 at 3:39






        • 1





          Thanks @Sidd, you will find exactly that suggestion and additional info in the link I provided to Ozgrid in my comment above.

          – Reafidy
          Aug 13 '12 at 4:15











        • True :) I should have visited that link :)

          – Siddharth Rout
          Aug 13 '12 at 4:17
















        75














        Lots of ways to do this. The most reliable is find.



        Dim rLastCell As Range

        Set rLastCell = ws.Cells.Find(What:="*", After:=ws.Cells(1, 1), LookIn:=xlFormulas, LookAt:= _
        xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, MatchCase:=False)

        MsgBox ("The last used column is: " & rLastCell.Column)


        If you want to find the last column used in a particular row you can use:



        Dim lColumn As Long

        lColumn = ws.Cells(1, Columns.Count).End(xlToLeft).Column


        Using used range (less reliable):



        Dim lColumn As Long

        lColumn = ws.UsedRange.Columns.Count


        Using used range wont work if you have no data in column A. See here for another issue with used range:



        See Here regarding resetting used range.






        share|improve this answer


























        • Perfect. Thank you.

          – Neat Machine
          Aug 13 '12 at 2:14













        • You welcome, more info here

          – Reafidy
          Aug 13 '12 at 2:15






        • 1





          + 1 readfidy :) A suggestion though... Always use Application.CountA with .Find to avoid errors. See this stackoverflow.com/questions/11883256/…

          – Siddharth Rout
          Aug 13 '12 at 3:39






        • 1





          Thanks @Sidd, you will find exactly that suggestion and additional info in the link I provided to Ozgrid in my comment above.

          – Reafidy
          Aug 13 '12 at 4:15











        • True :) I should have visited that link :)

          – Siddharth Rout
          Aug 13 '12 at 4:17














        75












        75








        75







        Lots of ways to do this. The most reliable is find.



        Dim rLastCell As Range

        Set rLastCell = ws.Cells.Find(What:="*", After:=ws.Cells(1, 1), LookIn:=xlFormulas, LookAt:= _
        xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, MatchCase:=False)

        MsgBox ("The last used column is: " & rLastCell.Column)


        If you want to find the last column used in a particular row you can use:



        Dim lColumn As Long

        lColumn = ws.Cells(1, Columns.Count).End(xlToLeft).Column


        Using used range (less reliable):



        Dim lColumn As Long

        lColumn = ws.UsedRange.Columns.Count


        Using used range wont work if you have no data in column A. See here for another issue with used range:



        See Here regarding resetting used range.






        share|improve this answer















        Lots of ways to do this. The most reliable is find.



        Dim rLastCell As Range

        Set rLastCell = ws.Cells.Find(What:="*", After:=ws.Cells(1, 1), LookIn:=xlFormulas, LookAt:= _
        xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, MatchCase:=False)

        MsgBox ("The last used column is: " & rLastCell.Column)


        If you want to find the last column used in a particular row you can use:



        Dim lColumn As Long

        lColumn = ws.Cells(1, Columns.Count).End(xlToLeft).Column


        Using used range (less reliable):



        Dim lColumn As Long

        lColumn = ws.UsedRange.Columns.Count


        Using used range wont work if you have no data in column A. See here for another issue with used range:



        See Here regarding resetting used range.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited May 23 '17 at 12:18









        Community

        11




        11










        answered Aug 13 '12 at 2:00









        ReafidyReafidy

        6,22533372




        6,22533372













        • Perfect. Thank you.

          – Neat Machine
          Aug 13 '12 at 2:14













        • You welcome, more info here

          – Reafidy
          Aug 13 '12 at 2:15






        • 1





          + 1 readfidy :) A suggestion though... Always use Application.CountA with .Find to avoid errors. See this stackoverflow.com/questions/11883256/…

          – Siddharth Rout
          Aug 13 '12 at 3:39






        • 1





          Thanks @Sidd, you will find exactly that suggestion and additional info in the link I provided to Ozgrid in my comment above.

          – Reafidy
          Aug 13 '12 at 4:15











        • True :) I should have visited that link :)

          – Siddharth Rout
          Aug 13 '12 at 4:17



















        • Perfect. Thank you.

          – Neat Machine
          Aug 13 '12 at 2:14













        • You welcome, more info here

          – Reafidy
          Aug 13 '12 at 2:15






        • 1





          + 1 readfidy :) A suggestion though... Always use Application.CountA with .Find to avoid errors. See this stackoverflow.com/questions/11883256/…

          – Siddharth Rout
          Aug 13 '12 at 3:39






        • 1





          Thanks @Sidd, you will find exactly that suggestion and additional info in the link I provided to Ozgrid in my comment above.

          – Reafidy
          Aug 13 '12 at 4:15











        • True :) I should have visited that link :)

          – Siddharth Rout
          Aug 13 '12 at 4:17

















        Perfect. Thank you.

        – Neat Machine
        Aug 13 '12 at 2:14







        Perfect. Thank you.

        – Neat Machine
        Aug 13 '12 at 2:14















        You welcome, more info here

        – Reafidy
        Aug 13 '12 at 2:15





        You welcome, more info here

        – Reafidy
        Aug 13 '12 at 2:15




        1




        1





        + 1 readfidy :) A suggestion though... Always use Application.CountA with .Find to avoid errors. See this stackoverflow.com/questions/11883256/…

        – Siddharth Rout
        Aug 13 '12 at 3:39





        + 1 readfidy :) A suggestion though... Always use Application.CountA with .Find to avoid errors. See this stackoverflow.com/questions/11883256/…

        – Siddharth Rout
        Aug 13 '12 at 3:39




        1




        1





        Thanks @Sidd, you will find exactly that suggestion and additional info in the link I provided to Ozgrid in my comment above.

        – Reafidy
        Aug 13 '12 at 4:15





        Thanks @Sidd, you will find exactly that suggestion and additional info in the link I provided to Ozgrid in my comment above.

        – Reafidy
        Aug 13 '12 at 4:15













        True :) I should have visited that link :)

        – Siddharth Rout
        Aug 13 '12 at 4:17





        True :) I should have visited that link :)

        – Siddharth Rout
        Aug 13 '12 at 4:17













        12














        I know this is old, but I've tested this in many ways and it hasn't let me down yet, unless someone can tell me otherwise.



        Row number



        Row = ws.Cells.Find(What:="*", After:=[A1] , SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row


        Column Letter



        ColumnLetter = Split(ws.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Cells.Address(1, 0), "$")(0)


        Column Number



        ColumnNumber = ws.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column





        share|improve this answer




























          12














          I know this is old, but I've tested this in many ways and it hasn't let me down yet, unless someone can tell me otherwise.



          Row number



          Row = ws.Cells.Find(What:="*", After:=[A1] , SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row


          Column Letter



          ColumnLetter = Split(ws.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Cells.Address(1, 0), "$")(0)


          Column Number



          ColumnNumber = ws.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column





          share|improve this answer


























            12












            12








            12







            I know this is old, but I've tested this in many ways and it hasn't let me down yet, unless someone can tell me otherwise.



            Row number



            Row = ws.Cells.Find(What:="*", After:=[A1] , SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row


            Column Letter



            ColumnLetter = Split(ws.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Cells.Address(1, 0), "$")(0)


            Column Number



            ColumnNumber = ws.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column





            share|improve this answer













            I know this is old, but I've tested this in many ways and it hasn't let me down yet, unless someone can tell me otherwise.



            Row number



            Row = ws.Cells.Find(What:="*", After:=[A1] , SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row


            Column Letter



            ColumnLetter = Split(ws.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Cells.Address(1, 0), "$")(0)


            Column Number



            ColumnNumber = ws.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Apr 19 '16 at 11:52









            xn1xn1

            168111




            168111























                2














                Try using the code after you active the sheet:



                Dim J as integer
                J = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row


                If you use Cells.SpecialCells(xlCellTypeLastCell).Row only, the problem will be that the xlCellTypeLastCell information will not be updated unless one do a "Save file" action. But use UsedRange will always update the information in realtime.






                share|improve this answer






























                  2














                  Try using the code after you active the sheet:



                  Dim J as integer
                  J = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row


                  If you use Cells.SpecialCells(xlCellTypeLastCell).Row only, the problem will be that the xlCellTypeLastCell information will not be updated unless one do a "Save file" action. But use UsedRange will always update the information in realtime.






                  share|improve this answer




























                    2












                    2








                    2







                    Try using the code after you active the sheet:



                    Dim J as integer
                    J = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row


                    If you use Cells.SpecialCells(xlCellTypeLastCell).Row only, the problem will be that the xlCellTypeLastCell information will not be updated unless one do a "Save file" action. But use UsedRange will always update the information in realtime.






                    share|improve this answer















                    Try using the code after you active the sheet:



                    Dim J as integer
                    J = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row


                    If you use Cells.SpecialCells(xlCellTypeLastCell).Row only, the problem will be that the xlCellTypeLastCell information will not be updated unless one do a "Save file" action. But use UsedRange will always update the information in realtime.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited May 22 '13 at 7:16









                    Rob

                    4,563124247




                    4,563124247










                    answered May 22 '13 at 6:55









                    PeterPeter

                    211




                    211























                        1














                        I think we can modify the UsedRange code from @Readify's answer above to get the last used column even if the starting columns are blank or not.



                        So this lColumn = ws.UsedRange.Columns.Count modified to



                        this lColumn = ws.UsedRange.Column + ws.UsedRange.Columns.Count - 1 will give reliable results always



                        enter image description here



                        ?Sheet1.UsedRange.Column + Sheet1.UsedRange.Columns.Count - 1


                        Above line Yields 9 in the immediate window.






                        share|improve this answer






























                          1














                          I think we can modify the UsedRange code from @Readify's answer above to get the last used column even if the starting columns are blank or not.



                          So this lColumn = ws.UsedRange.Columns.Count modified to



                          this lColumn = ws.UsedRange.Column + ws.UsedRange.Columns.Count - 1 will give reliable results always



                          enter image description here



                          ?Sheet1.UsedRange.Column + Sheet1.UsedRange.Columns.Count - 1


                          Above line Yields 9 in the immediate window.






                          share|improve this answer




























                            1












                            1








                            1







                            I think we can modify the UsedRange code from @Readify's answer above to get the last used column even if the starting columns are blank or not.



                            So this lColumn = ws.UsedRange.Columns.Count modified to



                            this lColumn = ws.UsedRange.Column + ws.UsedRange.Columns.Count - 1 will give reliable results always



                            enter image description here



                            ?Sheet1.UsedRange.Column + Sheet1.UsedRange.Columns.Count - 1


                            Above line Yields 9 in the immediate window.






                            share|improve this answer















                            I think we can modify the UsedRange code from @Readify's answer above to get the last used column even if the starting columns are blank or not.



                            So this lColumn = ws.UsedRange.Columns.Count modified to



                            this lColumn = ws.UsedRange.Column + ws.UsedRange.Columns.Count - 1 will give reliable results always



                            enter image description here



                            ?Sheet1.UsedRange.Column + Sheet1.UsedRange.Columns.Count - 1


                            Above line Yields 9 in the immediate window.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited May 23 '17 at 11:54









                            Community

                            11




                            11










                            answered Mar 11 '16 at 16:36









                            newguynewguy

                            1,86121846




                            1,86121846























                                1














                                Here's something which might be useful. Selecting the entire column based on a row containing data, in this case i am using 5th row:



                                Dim lColumn As Long

                                lColumn = ActiveSheet.Cells(5, Columns.Count).End(xlToLeft).Column
                                MsgBox ("The last used column is: " & lColumn)





                                share|improve this answer


























                                • What makes your answer different then the accepted answer, besides being shorter? Also please avoid the use of the Select statement. That is really bad practice. See stackoverflow.com/questions/10714251/…

                                  – Luuklag
                                  Jun 28 '18 at 10:14











                                • it's short and simple and that's the value added. thanks for the tip on the Select statement. I will have a look. Cheers

                                  – dapaz
                                  Jun 29 '18 at 7:50
















                                1














                                Here's something which might be useful. Selecting the entire column based on a row containing data, in this case i am using 5th row:



                                Dim lColumn As Long

                                lColumn = ActiveSheet.Cells(5, Columns.Count).End(xlToLeft).Column
                                MsgBox ("The last used column is: " & lColumn)





                                share|improve this answer


























                                • What makes your answer different then the accepted answer, besides being shorter? Also please avoid the use of the Select statement. That is really bad practice. See stackoverflow.com/questions/10714251/…

                                  – Luuklag
                                  Jun 28 '18 at 10:14











                                • it's short and simple and that's the value added. thanks for the tip on the Select statement. I will have a look. Cheers

                                  – dapaz
                                  Jun 29 '18 at 7:50














                                1












                                1








                                1







                                Here's something which might be useful. Selecting the entire column based on a row containing data, in this case i am using 5th row:



                                Dim lColumn As Long

                                lColumn = ActiveSheet.Cells(5, Columns.Count).End(xlToLeft).Column
                                MsgBox ("The last used column is: " & lColumn)





                                share|improve this answer















                                Here's something which might be useful. Selecting the entire column based on a row containing data, in this case i am using 5th row:



                                Dim lColumn As Long

                                lColumn = ActiveSheet.Cells(5, Columns.Count).End(xlToLeft).Column
                                MsgBox ("The last used column is: " & lColumn)






                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited Jun 29 '18 at 7:48

























                                answered Jun 27 '18 at 9:09









                                dapazdapaz

                                341315




                                341315













                                • What makes your answer different then the accepted answer, besides being shorter? Also please avoid the use of the Select statement. That is really bad practice. See stackoverflow.com/questions/10714251/…

                                  – Luuklag
                                  Jun 28 '18 at 10:14











                                • it's short and simple and that's the value added. thanks for the tip on the Select statement. I will have a look. Cheers

                                  – dapaz
                                  Jun 29 '18 at 7:50



















                                • What makes your answer different then the accepted answer, besides being shorter? Also please avoid the use of the Select statement. That is really bad practice. See stackoverflow.com/questions/10714251/…

                                  – Luuklag
                                  Jun 28 '18 at 10:14











                                • it's short and simple and that's the value added. thanks for the tip on the Select statement. I will have a look. Cheers

                                  – dapaz
                                  Jun 29 '18 at 7:50

















                                What makes your answer different then the accepted answer, besides being shorter? Also please avoid the use of the Select statement. That is really bad practice. See stackoverflow.com/questions/10714251/…

                                – Luuklag
                                Jun 28 '18 at 10:14





                                What makes your answer different then the accepted answer, besides being shorter? Also please avoid the use of the Select statement. That is really bad practice. See stackoverflow.com/questions/10714251/…

                                – Luuklag
                                Jun 28 '18 at 10:14













                                it's short and simple and that's the value added. thanks for the tip on the Select statement. I will have a look. Cheers

                                – dapaz
                                Jun 29 '18 at 7:50





                                it's short and simple and that's the value added. thanks for the tip on the Select statement. I will have a look. Cheers

                                – dapaz
                                Jun 29 '18 at 7:50





                                protected by Community Oct 23 '17 at 14:26



                                Thank you for your interest in this question.
                                Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                                Would you like to answer one of these unanswered questions instead?



                                Popular posts from this blog

                                How to change which sound is reproduced for terminal bell?

                                Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

                                Can I use Tabulator js library in my java Spring + Thymeleaf project?