G Guest Apr 19, 2004 #1 Can anyone please help me with some code to return the column number of the last cell in a selected range TIA
Can anyone please help me with some code to return the column number of the last cell in a selected range TIA
I incjourn Apr 19, 2004 #2 This might not be the best way but it works ----------------------------------- For Each B In Selection C = B.Column Next B lastcol = C
This might not be the best way but it works ----------------------------------- For Each B In Selection C = B.Column Next B lastcol = C
N Norman Jones Apr 19, 2004 #3 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 Click to expand... the last cell in a selected range?
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 Click to expand... the last cell in a selected range?
B Bob Phillips Apr 19, 2004 #4 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 Click to expand... 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 Click to expand... the last cell in a selected range?
N Norman Jones Apr 19, 2004 #5 Hi Bob, I suspect that this (elegantly) returns the last column in the sheet rather than the selection.
Hi Bob, I suspect that this (elegantly) returns the last column in the sheet rather than the selection.
R Rob van Gelder Apr 19, 2004 #6 I have some examples in the Working with Ranges section of my website. -- Rob van Gelder - http://www.vangelder.co.nz/excel Lawlera said: Can anyone please help me with some code to return the column number of Click to expand... the last cell in a selected range?
I have some examples in the Working with Ranges section of my website. -- Rob van Gelder - http://www.vangelder.co.nz/excel Lawlera said: Can anyone please help me with some code to return the column number of Click to expand... the last cell in a selected range?
B Bob Phillips Apr 19, 2004 #8 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)
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)