Last column in selection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can anyone please help me with some code to return the column number of the last cell in a selected range

TIA
 
This might not be the best way but it works

-----------------------------------

For Each B In Selection
C = B.Column
Next B

lastcol = C
 
Hi Lawlera,

Try

selection(selection.cells.count).column

---
Regards,
Norman.

Lawlera said:
Can anyone please help me with some code to return the column number of
the last cell in a selected range?
 
With ActiveSheet.UsedRange
iCol = .Columns.Count + .Cells(1, 1).Column - 1
End With



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

Lawlera said:
Can anyone please help me with some code to return the column number of
the last cell in a selected range?
 
Hi Bob,

I suspect that this (elegantly) returns the last column in the sheet rather
than the selection.
 
Lots of answers .. all different

Got what I needed so thanks to everyone!
 
You are correct, for Selectiuon it should be

With Selection
iCol = .Columns.Count + .Cells(1, 1).Column - 1
End With

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top