Don,
Thanks for the response. It works, except with one exception. If the
sheet is empty it selects first 4 columns instead of 2.
I had preiously tried this code:
Range("IV1").End(xlToLeft).Select
ActiveCell.Offset(0, 2).Select
It worked to paste data into the last 2 columns but it left colums A&B empty
if the sheet was empty (obviously).
I am not sure quite how to make a IF statement that would check the sheet to
see if A&B were empty on the first go round then select them. If not then
do the code you sent me. I suppose the code you sent me would work, but it
selects 4 colums when empty rather than 2. If I knew enough about the below
code I would make an attempt but not sure on how all of the code works.
"Don Guillett" wrote in message
...
try either
Sub selectlast2emptycolumns() 'two ways
'x = Cells(5, Columns.Count).End(xlToLeft).Address
'Range(x).Offset(0, 1).Resize(1, 2).EntireColumn.Select
x = Cells(5, Columns.Count).End(xlToLeft).Column + 1
Range(Cells(5, x), Cells(5, x + 1)).EntireColumn.Select
End Sub
--
Don Guillett
SalesAid Software
"Nathan Bell" wrote in message
...
All,
I am trying to determine the code to select the 2 last empty columns
in
Excel via VBA. The only code I can find is
Range("IV5").End(xlToLeft).Select the only reason for that is row 5
contains data and 1-4 don't, thus returning results further left than I
wanted when doing a paste.
Again I am trying to select the last 2 empty columns in a worksheet.
What
would be the most effective way to do this?
Regards,
Nathan