View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.newusers
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default pick up last occupied cell to the left macro

This will even determine the column to copy to. If you want col J change
Cells(i, lc).value = Cells(i, Columns.Count).End(xlToLeft).value
to
Cells(i, "j").value = Cells(i, Columns.Count).End(xlToLeft).value


Sub lineemup()
lc = Cells.SpecialCells(xlCellTypeLastCell).Column + 1
lr = Cells.SpecialCells(xlCellTypeLastCell).Row
'MsgBox lc
'MsgBox lr
For i = 1 To lr
Cells(i, lc).value = Cells(i, Columns.Count).End(xlToLeft).value
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Meanie" wrote in message
...
I'm trying to clean up .pdf data that was exported to Excel. The columns
are
a mess so I'm working left to right. I was hoping to create a macro that
would pick up the last occupied cell to the left. It is not always in the
same column but when I run the macro, it always goes to the same column.
Is
there a way to say "+, ctrl left arrow, enter" and have it repeat
everytime
hit the hotkey assigned?

Or... Does anyone know a better way to clean up a worksheet?