Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default 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
.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to copy text between two different delimeters [email protected] New Users to Excel 1 April 6th 07 03:54 PM
copy text from 1 workbook to another by macro bigdaddy3 Excel Worksheet Functions 0 August 17th 05 06:20 PM
Adding new numbers as I type without duplicates from Sheet1,ColumnA to Sheet2,ColumnA Master Excel Worksheet Functions 2 July 12th 05 05:03 PM
Macro to delete a text box and copy in new one Dave Excel Discussion (Misc queries) 1 February 18th 05 02:02 AM
Macro to copy daily text file Cheryl[_4_] Excel Programming 1 May 27th 04 05:46 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"