Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Find and replace

Hi - stuck on an issue here
I am looking to search through a column and any cells that do not have an
entry whose first three characters are ORD or 'B'ORD or GBP etc.
If the entry in the cell does not start with any of these 3 characters, i
would like to copy that cell and paste its contents into another place, on
the same row, 10 cells to the left of the copied cell.

eg: If column AG2 is "GBP STERLING" macro will move on..... If AG3 reads
"ORD 64" the macro will move on, but if AG4 is "BLK GOL" that entry will be
copied, and pasted into cell W4. The macro will continue down column AG
until there is no data.

Stumped by this one - can anyone help?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Find and replace

Hi,

entry whose first three characters are ORD or 'B'ORD or GBP etc.


The second of your arguments isn't 3 characters long and etc isn't very
helpful so I've gone with just 3 characters and ignored etc.

Try this

Sub Versive()
lastrow = Cells(Cells.Rows.Count, "AG").End(xlUp).Row
Set MyRange = Range("AG1:AG" & lastrow)
S = "ORD,BOR,GBP"
v = Split(S, ",")
For Each c In Range("AG1:AG" & lastrow)
If IsError(Application.Match(CStr(Left(c.Value, 3)), v, 0)) Then
c.Offset(, -10).Value = c.Value
End If
Next c
End Sub


Mike

"Withnails" wrote:

Hi - stuck on an issue here
I am looking to search through a column and any cells that do not have an
entry whose first three characters are ORD or 'B'ORD or GBP etc.
If the entry in the cell does not start with any of these 3 characters, i
would like to copy that cell and paste its contents into another place, on
the same row, 10 cells to the left of the copied cell.

eg: If column AG2 is "GBP STERLING" macro will move on..... If AG3 reads
"ORD 64" the macro will move on, but if AG4 is "BLK GOL" that entry will be
copied, and pasted into cell W4. The macro will continue down column AG
until there is no data.

Stumped by this one - can anyone help?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Find and replace

it works but not when i have it in VBA. it asks me to define the
variable/object of c in 'Each c In Range.... etc

Any ideas?

"Mike H" wrote:

Hi,

entry whose first three characters are ORD or 'B'ORD or GBP etc.


The second of your arguments isn't 3 characters long and etc isn't very
helpful so I've gone with just 3 characters and ignored etc.

Try this

Sub Versive()
lastrow = Cells(Cells.Rows.Count, "AG").End(xlUp).Row
Set MyRange = Range("AG1:AG" & lastrow)
S = "ORD,BOR,GBP"
v = Split(S, ",")
For Each c In Range("AG1:AG" & lastrow)
If IsError(Application.Match(CStr(Left(c.Value, 3)), v, 0)) Then
c.Offset(, -10).Value = c.Value
End If
Next c
End Sub


Mike

"Withnails" wrote:

Hi - stuck on an issue here
I am looking to search through a column and any cells that do not have an
entry whose first three characters are ORD or 'B'ORD or GBP etc.
If the entry in the cell does not start with any of these 3 characters, i
would like to copy that cell and paste its contents into another place, on
the same row, 10 cells to the left of the copied cell.

eg: If column AG2 is "GBP STERLING" macro will move on..... If AG3 reads
"ORD 64" the macro will move on, but if AG4 is "BLK GOL" that entry will be
copied, and pasted into cell W4. The macro will continue down column AG
until there is no data.

Stumped by this one - can anyone help?

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
Find and Replace - Replace with Blank Space Studebaker Excel Discussion (Misc queries) 4 April 3rd 23 10:55 AM
Find/Replace Event or Find/Replace for Protected Sheet ... Joe HM Excel Programming 2 October 27th 07 03:55 PM
find and replace - replace data in rows to separated by commas msdker Excel Worksheet Functions 1 April 15th 06 01:00 AM
Using Find and Replace to replace " in a macro snail30152 Excel Programming 1 April 13th 06 11:58 PM
Replace method - cannot find any data to replace Mike Excel Programming 5 April 6th 06 08:56 PM


All times are GMT +1. The time now is 04:56 AM.

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

About Us

"It's about Microsoft Excel"