ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to copy text from ColumnA to B (https://www.excelbanter.com/excel-programming/305574-macro-copy-text-columna-b.html)

Sarah[_4_]

Macro to copy text from ColumnA to B
 
Need a macro to copy all rows with the text "sh cam" from
column A to column B.
This is an example only shows 3 examples but my excel
spreadsheet has over 2000.

Column A

Jim Glover
sh cam 00-08-74-34-48
Tammy Smith
sh cam 00-75-38-d9-39
Sam Dover
sh cam 00-08-28-23-23

Thanks
Sarah

chuck

Macro to copy text from ColumnA to B
 
Sub Move_A_to_B()
For MyRow = 1 To 2000 ' change 2000 to your last row
MyValue = Range("a" & MyRow).Value
If Left(MyValue, 6) = "sh cam" Then
Range("b" & MyRow).Value = "sh cam"
Range("a" & MyRow).ClearContents
End If
Next MyRow
End Sub

Tom Ogilvy

Macro to copy text from ColumnA to B
 
Dim rng as Range, rng1 as Range
Dim sForm as String

columns(2).Insert
set rng = Range(cells(1,1),cells(rows.count,1).End(xlup))
sForm = "=IF(ISERROR(SEARCH(""sh cam"",A1)),"""",NA())"

rng.offset(0,1).Formla = sForm
on Error Resume Next
set rng1 = rng.offset(0,1).SpecialCells(xlFormulas,xlErrors)
set rng1 = Intersect(Columns(1),rng1.EntireRow)
On Error goto 0
columns(2).Delete
if not rng1 is nothing then
rng1.EntireRow.copy Destination:= _
worksheets("sheet2").Range("A1")
End if

--
Regards,
Tom Ogilvy


"Sarah" wrote in message
...
Need a macro to copy all rows with the text "sh cam" from
column A to column B.
This is an example only shows 3 examples but my excel
spreadsheet has over 2000.

Column A

Jim Glover
sh cam 00-08-74-34-48
Tammy Smith
sh cam 00-75-38-d9-39
Sam Dover
sh cam 00-08-28-23-23

Thanks
Sarah




No Name

Macro to copy text from ColumnA to B
 
Sarah:
If the answers you got are to complicated let me know.


-----Original Message-----
Need a macro to copy all rows with the text "sh cam" from
column A to column B.
This is an example only shows 3 examples but my excel
spreadsheet has over 2000.

Column A

Jim Glover
sh cam 00-08-74-34-48
Tammy Smith
sh cam 00-75-38-d9-39
Sam Dover
sh cam 00-08-28-23-23

Thanks
Sarah
.


SARAH

Macro to copy text from ColumnA to B
 
THANKS ALOT!!!!!!!!!!!!!!!!!!!!!!!!!
WORKS PERFECT
-----Original Message-----
Dim rng as Range, rng1 as Range
Dim sForm as String

columns(2).Insert
set rng = Range(cells(1,1),cells(rows.count,1).End(xlup))
sForm = "=IF(ISERROR(SEARCH(""sh cam"",A1)),"""",NA())"

rng.offset(0,1).Formla = sForm
on Error Resume Next
set rng1 = rng.offset(0,1).SpecialCells

(xlFormulas,xlErrors)
set rng1 = Intersect(Columns(1),rng1.EntireRow)
On Error goto 0
columns(2).Delete
if not rng1 is nothing then
rng1.EntireRow.copy Destination:= _
worksheets("sheet2").Range("A1")
End if

--
Regards,
Tom Ogilvy


"Sarah" wrote in

message
...
Need a macro to copy all rows with the text "sh cam"

from
column A to column B.
This is an example only shows 3 examples but my excel
spreadsheet has over 2000.

Column A

Jim Glover
sh cam 00-08-74-34-48
Tammy Smith
sh cam 00-75-38-d9-39
Sam Dover
sh cam 00-08-28-23-23

Thanks
Sarah



.



All times are GMT +1. The time now is 06:10 PM.

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