Need Help moving text from one cell location to another

rsajdak

New Member
Joined
Nov 3, 2005
Messages
4
I was hoping someone here could help me with a macro.

I have a spreadsheet that has all of Column A blank
Column B contains about 1000 rows of text, which has the following layout: spec name “SI_xxxxx”, then below it text describing the spec. This repeats over and over going down the rows

What is want to do is to 1) verify that the cell is a spec by confirming that it begins with “SI_”, 2) move the spec name left into column A and then down one row so that it is immediately left of the its description in Column B, 3) repeat this process all the way down the row until the end.

If anyone could help, I’d greatly appreciate it.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Welcome to MrExcel -

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> foo()
<SPAN style="color:#00007F">Dim</SPAN> c <SPAN style="color:#00007F">As</SPAN> Range
Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN>
<SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> c <SPAN style="color:#00007F">In</SPAN> Range("B1:B" & Cells(Rows.Count, 2).End(xlUp).Row).SpecialCells(xlCellTypeConstants)
    <SPAN style="color:#00007F">If</SPAN> c.Value <SPAN style="color:#00007F">Like</SPAN> "SI_*" <SPAN style="color:#00007F">Then</SPAN>
        c.Offset(1, -1).Value = c.Value
        c.Value = vbNullString
    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">Next</SPAN> c
Application.ScreenUpdating = <SPAN style="color:#00007F">True</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0
Thank you very much that worked awesome!!

I forget to specify one thing though: Can the macro be customized to that it only affects a shaded range that I define with the mouse?

Thank you in advance.
 
Upvote 0
rsajdak said:
Thank you very much that worked awesome!!

I forget to specify one thing though: Can the macro be customized to that it only affects a shaded range that I define with the mouse?

Thank you in advance.

Sure --

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> foo()
<SPAN style="color:#00007F">Dim</SPAN> c <SPAN style="color:#00007F">As</SPAN> Range
Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN>
<SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> c <SPAN style="color:#00007F">In</SPAN> Selection.SpecialCells(xlCellTypeConstants)
    <SPAN style="color:#00007F">If</SPAN> c.Value <SPAN style="color:#00007F">Like</SPAN> "SI_*" <SPAN style="color:#00007F">Then</SPAN>
        c.Offset(1, -1).Value = c.Value
        c.Value = vbNullString
    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">Next</SPAN> c
Application.ScreenUpdating = <SPAN style="color:#00007F">True</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>


</FONT>
 
Upvote 0
THANK YOU THANK YOU. I worked great! I have 4000 lines that I though I had to sort by hand. You saved me!
 
Upvote 0

Forum statistics

Threads
1,214,386
Messages
6,119,216
Members
448,876
Latest member
Solitario

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top