Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Is there a way to move cells beginning with '0A' from Col B to Col C?
|
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Can't shift cells up or down | Excel Discussion (Misc queries) | |||
how do I shift the contents of the cells up to remove empty cells. | Excel Discussion (Misc queries) | |||
How to delete all the blanc cells in a worksheet and shift cells l | Excel Discussion (Misc queries) | |||
Shift cells up or down | Excel Discussion (Misc queries) | |||
Skip cells with TAB/SHIFT+TAB but allow arrow keys/mouse selection of skipped cells | Excel Programming |