ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to select "last used column + 1" (https://www.excelbanter.com/excel-programming/393087-macro-select-last-used-column-1-a.html)

johan

Macro to select "last used column + 1"
 
Hello,

Is there a simple macro to select column C till the last one + 1
column extra.
For example....
I used column C till K, so... I want to select C till L (one more
than the last one used).

regards,
Johan


Gary Keramidas

Macro to select "last used column + 1"
 
you don't say how many rows are involved, so this just selects row 1. maybe you
can adapt it. i just use select here as an example.

Sub test()
Dim ws As Worksheet
Dim lastcol As Long
Set ws = Worksheets("Sheet1")
lastcol = ws.Cells(1, Columns.Count).End(xlToLeft).Column + 1
ws.Range(ws.Cells(1, 3), ws.Cells(1, lastcol)).Select
End Sub

--


Gary


"johan" wrote in message
ps.com...
Hello,

Is there a simple macro to select column C till the last one + 1
column extra.
For example....
I used column C till K, so... I want to select C till L (one more
than the last one used).

regards,
Johan





All times are GMT +1. The time now is 12:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com