Last column in selection
Can anyone please help me with some code to return the column number of the last cell in a selected range
TIA |
Last column in selection
This might not be the best way but it works
----------------------------------- For Each B In Selection C = B.Column Next B lastcol = C ----------------------------------- Regard -- Message posted from http://www.ExcelForum.com |
Last column in selection
Hi Lawlera,
Try selection(selection.cells.count).column --- Regards, Norman. "Lawlera" wrote in message ... Can anyone please help me with some code to return the column number of the last cell in a selected range? TIA |
Last column in selection
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" wrote in message ... Can anyone please help me with some code to return the column number of the last cell in a selected range? TIA |
Last column in selection
Hi Bob,
I suspect that this (elegantly) returns the last column in the sheet rather than the selection. --- Regards, Norman Jones "Bob Phillips" wrote in message ... 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" wrote in message ... Can anyone please help me with some code to return the column number of the last cell in a selected range? TIA |
Last column in selection
I have some examples in the Working with Ranges section of my website.
-- Rob van Gelder - http://www.vangelder.co.nz/excel "Lawlera" wrote in message ... Can anyone please help me with some code to return the column number of the last cell in a selected range? TIA |
Last column in selection
Lots of answers .. all different
Got what I needed so thanks to everyone! |
Last column in selection
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) "Norman Jones" wrote in message ... Hi Bob, I suspect that this (elegantly) returns the last column in the sheet rather than the selection. --- Regards, Norman Jones "Bob Phillips" wrote in message ... 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" wrote in message ... Can anyone please help me with some code to return the column number of the last cell in a selected range? TIA |
All times are GMT +1. The time now is 08:47 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com