#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 80
Default Shift cells

Is there a way to move cells beginning with '0A' from Col B to Col C?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,514
Default Shift cells

gary wrote :
Is there a way to move cells beginning with '0A' from Col B to Col C?


Do you mean IF the colB cell contents begin with "OA" then you want to
move the contents to colC and clear the contents from the cell in colB?
If so then you need to loop the range and use either the Left$()
function to see if the 1st 2 characters = "OA",

or use the InStr() function to see if "OA" = 1 for position.

Either would be nested in an If...Then construct.

Use a For Each loop to iterate colB.
Use Offset(, 1) to put the value in colC
Use .ClearContents on the cell in colB

<aircode
Dim c As Range
For Each c In Range("B1:B?") 'edit range address to suit
If InStr(1, c.Text, "OA") = 1 Then '//comment out to suit
'//or...
If Left$(c.Text, 2) = "OA" Then '//comment out to suit
c.Offset(, 1) = c.Value: c.ClearContents
End If
Next 'c
</aircode

If there's a lot of cells to process then I suggest 'dumping' the range
(both cols) into an array, work the array in memory, then 'dump' the
data back into the sheet. In this case you'd use a counter with
For...Next.

<aircode
Dim v As Variant, i As Long
v = Range("B1:C?") 'edit range address to suit
For i = LBound(v) To UBound(v)
If Left(v(i, 1), 2) = "OA" Then '//comment out to suit
'//or...
If InStr(1, v(i, 1), "OA") = 1 Then '//comment out to suit
v(i, 2) = v(i, 1): v(i, 1) = vbNullString
End If
Next 'i
Range("B1:C?") = v 'edit range address to suit
</aircode

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


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
Can't shift cells up or down Tim Excel Discussion (Misc queries) 0 January 26th 10 05:46 PM
how do I shift the contents of the cells up to remove empty cells. auctioncoach Excel Discussion (Misc queries) 2 February 11th 09 06:15 PM
How to delete all the blanc cells in a worksheet and shift cells l tiramisu Excel Discussion (Misc queries) 2 December 7th 06 03:45 AM
Shift cells up or down Rosemary Excel Discussion (Misc queries) 3 September 30th 06 02:44 PM
Skip cells with TAB/SHIFT+TAB but allow arrow keys/mouse selection of skipped cells Wescotte Excel Programming 1 June 6th 05 07:00 PM


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