ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copying part of a string to another cell (https://www.excelbanter.com/excel-programming/418867-copying-part-string-another-cell.html)

Chad[_3_]

Copying part of a string to another cell
 
Hi All,

Is there an easy way to do this?
I want to copy the first 6 characters from [A1] to [K1], [A2]..[K2] all the
way to last row.

I am assuming I will have to use a loop and use the Left command. I was
just hoping for an easier way since it is the entire column.

Chad



JLGWhiz

Copying part of a string to another cell
 
this should work. Put it in the standard code module1


Sub cpyAtoK()
Dim c As Range
lstRow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
Set aRng = ActiveSheet.Range("A1:A" & lstRow)
For Each c In aRng
If Not c Is Nothing Then
c.Offset(0, 10) = Left(Trim(c.Value), 6)
End If
Next
End Sub


"Chad" wrote:

Hi All,

Is there an easy way to do this?
I want to copy the first 6 characters from [A1] to [K1], [A2]..[K2] all the
way to last row.

I am assuming I will have to use a loop and use the Left command. I was
just hoping for an easier way since it is the entire column.

Chad





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

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