Find Last Column With Data

  • i want a formula that takes a value from the 3rd to last" column to the left of the last column


    but the last column is not static. so 1) i need to find the last column. and then 2) i need to take a value from the column 3 columns to the left of the last column. how do i do that using excel formulas?


    thanks!

  • Re: Find Last Column With Data


    Hi


    you can do this in VBA


    Code
    Dim SelectColumn as Integer
    SelectColumn = ActiveCell.SpecialCells(xlCellTypeLastCell).Column -3


    I am not sure it can be done with formulae


    Robert

  • Re: Find Last Column With Data


    Hey there!


    Quote from finnstones

    i want a formula that takes a value from the 3rd to last" column to the left of the last column


    but the last column is not static. so 1) i need to find the last column. and then 2) i need to take a value from the column 3 columns to the left of the last column. how do i do that using excel formulas?


    thanks!


    Ok, I think I managed to decypher that question... The following code should work, as long as you ment copy the information from the 3rd row from last of any given row.



    Hopefully you had VBA in mind...


    Ciao!

  • Re: Find Last Column With Data


    Code
    Sub FindLastColumn()
    Dim LastColumn As Integer
    	If WorksheetFunction.CountA(Cells) > 0 Then
    		'Search for any entry, by searching backwards by Columns.
    		LastColumn = Cells.Find(What:="*", After:=[A1], _
            		           SearchOrder:=xlByColumns, _
            			   SearchDirection:=xlPrevious).Column
    				   MsgBox Cells(1,LastColumn).EntireColumn.Address
    	End If 
    End Sub

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!