LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default If Then Code Question

Let me re-ask my question perhaps more intelligently and more fully. My goal
is to scan a spreadsheet with data in many columns but in many cases the data
is in the wrong column. The data all starts with a string which easily
identifies which column it should go into. For example if my columns were
Fruit, Cars, People, the data would be Fruit: apply, or Cars: Chevy, or
People: Men. So I need a code which looks at each cell for a certain word
and place that whole cell's contents/string into the right column (which I
would rather set aside away as an extra column). The ROW should stay the
SAME though since the other rows/columns may be okay? (unless I just write a
code to move it all (which would be nice). Hope that was clear. here's what
I have that doesn't work. Any help would be very greatly appreciated as I
continue to read and learn early in this new "career."

Sub Macro1()

Set myrange = ActiveSheet.Range(Selection, Selection.End(xlUp))
For Each cell In myrange
If Left(cell.Value, 5) = "GL Op" Then
cell.Cut
cell.Paste ("GL Op")
ElseIf Left(cell.Value, 5) = "Au Op" Then
cell.Cut
cell.Paste ("Au Op")
ElseIf Left(cell.Value, 5) = "WC Op" Then
cell.Cut
cell.Paste ("WC Op")
ElseIf Left(cell.Value, 5) = "CA Op" Then
cell.Cut
cell.Paste ("Au Op")
End If
Next cell

End Sub
 
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
code question Shu of AZ Excel Discussion (Misc queries) 2 July 12th 08 01:10 AM
Code Question kirkm[_6_] Excel Programming 1 February 8th 07 02:19 AM
VBA Code Question Theresa[_4_] Excel Programming 6 October 16th 03 07:06 PM
VBA CODE Question Gary[_5_] Excel Programming 2 July 29th 03 03:45 AM


All times are GMT +1. The time now is 02:17 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"