ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Determine last col with data (https://www.excelbanter.com/excel-programming/274747-determine-last-col-data.html)

ian

Determine last col with data
 
Need a macro to determine the last col to the right(blanks in between) anc
copy last col to sheet1
Thanks



ian

Determine last col with data
 
Sorry for the misunderstanding.
I need a macro to find and copy the last col on a worksheet(There will be
blanks between Col A and the last col on the right


"Ron de Bruin" wrote in message
...
You can use a function for that Ian

Function Lastcol(sh As Worksheet)
On Error Resume Next
Lastcol = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Column
On Error GoTo 0
End FunctionOn this page tou can find some example codehow you can use
ithttp://www.rondebruin.nl/copy1.htm
--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Ron de Bruin" wrote in message
...
Last col in a row or last col in the worksheet Ian??

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"ian" wrote in message
ble.rogers.com...
Need a macro to determine the last col to the right(blanks in between)

anc
copy last col to sheet1
Thanks









Ron de Bruin

Determine last col with data
 
See the link I posted there you can see how you can use the
function result in your macro.



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"ian" wrote in message
able.rogers.com...
Sorry for the misunderstanding.
I need a macro to find and copy the last col on a worksheet(There will be
blanks between Col A and the last col on the right


"Ron de Bruin" wrote in message
...
You can use a function for that Ian

Function Lastcol(sh As Worksheet)
On Error Resume Next
Lastcol = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Column
On Error GoTo 0
End FunctionOn this page tou can find some example codehow you can use
ithttp://www.rondebruin.nl/copy1.htm
--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Ron de Bruin" wrote in message
...
Last col in a row or last col in the worksheet Ian??

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"ian" wrote in message
ble.rogers.com...
Need a macro to determine the last col to the right(blanks in

between)
anc
copy last col to sheet1
Thanks











Ron de Bruin

Determine last col with data
 
http://www.rondebruin.nl/copy1.htm


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Ron de Bruin" wrote in message
...
See the link I posted there you can see how you can use the
function result in your macro.



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"ian" wrote in message
able.rogers.com...
Sorry for the misunderstanding.
I need a macro to find and copy the last col on a worksheet(There will

be
blanks between Col A and the last col on the right


"Ron de Bruin" wrote in message
...
You can use a function for that Ian

Function Lastcol(sh As Worksheet)
On Error Resume Next
Lastcol = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Column
On Error GoTo 0
End FunctionOn this page tou can find some example codehow you can use
ithttp://www.rondebruin.nl/copy1.htm
--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Ron de Bruin" wrote in message
...
Last col in a row or last col in the worksheet Ian??

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"ian" wrote in message
ble.rogers.com...
Need a macro to determine the last col to the right(blanks in

between)
anc
copy last col to sheet1
Thanks














All times are GMT +1. The time now is 08:05 AM.

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