Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Last column in selection
Lots of answers .. all different
Got what I needed so thanks to everyone! |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro help - add column selection | Excel Worksheet Functions | |||
Copy Selection - Transpose Selection - Delete Selection | Excel Discussion (Misc queries) | |||
Automate column selection | Setting up and Configuration of Excel | |||
Macro column selection | Excel Programming | |||
Total by Selection by Column, Help Please. | Excel Programming |