Search : in
By :

Move cells to the next column

Last answer on Feb 3, 2009 11:59:00 pm GMT mariasyrny, on Feb 3, 2009 2:50:43 pm GMT 
 Report this message to moderators

Hello,

I have a report that comes already formated for printing. However, I want to be able to manipulate the data to analyze it. Currently the report has a colums with employee's name and the division they belong to right below their name. I want to create a colum adjecent to their name called division and move their assigned division over. I could do it with a drag and drop but we are talking about several hundred employees. And to complicate things, there are empty cells between one employee and the next, for example:

Name

Joe Smith
yellow team


Mary Sue
blue team

Carol Who
red team

I would like to delete the spaces (empty cells) and move their team name to the next colum over. Can I run a Macro for that?

Configuration: Windows XP
Internet Explorer 7.0

Best answers for « Move cells to the next column » in :
VBA macro to move to the cell 'underneath' ShowVBA macro to move to the cell 'underneath' Issue Solution Issue If you need need VBA macro to move to the cell 'underneath' the particular button that is being pressed, series of buttons down the page, each will run the same macro/do...
Excel - Extract identical cells of 2 columns ShowExcel - Extract identical cells of 2 columns Issue Solution Note Issue Hello, Got a list of words in column A Got a list of words in column B I am looking for a formula that will produce in column C a list of the words that...
Basic Excel Formulas ShowBasic Excel Formulas Below are some basic formulas for Microsoft excel: Basic formula : ADDITION cell A1 to A10 = sum (A1: A10) AVERAGE cell A1 to A10 = average (A1: A10) MAXIMUM cell A1 to A10 = max (A1: A10) MINIMUM...
Worksheet - Cells ShowThe Concept of a Cell A "cell" is the intersection between a line (horizontal) and a column (vertical) on a worksheet. Thus, the name of the line combined with the name of the column gives the cell's coordinates (the term address is sometimes also...
Spreadsheets - Cell Selection ShowCell Selection Spreadsheets are powerful tools for working with data. However, to work with data, it is necessary to have tools to rapidly choose the required cells. Line Selection An entire line can be chosen by clicking directly on the line...

1

 Helper, on Feb 3, 2009 11:59:00 pm GMT

Assumption:
The employee names are in Column A


Private Sub CommandButton1_Click()

Dim i
Dim dup
Dim r
r = Range("A65536").End(xlUp).Row 'This will find the last used row regardless of empty cells
i = 1

Columns("B:B").Select 'You stated creating a column so I assume you want to insert column for the team name
Selection.Insert Shift:=xlToRight

'This will first move the team names beside the person's name and delete the team name.
For i = i To r

If Not IsEmpty(Range("A" & i)) And Right(Range("A" & i), 4) = "team" Then
dup = i

Range("B" & i).Offset(-1, 0) = Range("A" & dup)
Rows(dup).EntireRow.Delete Shift:=xlUp

End If

Next i

i = 1
'Now we can delete the empty rows
Rows(r).Select
For r = r To i Step -1

If Range("A" & r) = "" Then
Rows(r).EntireRow.Delete
End If

Next r

Range("A1").Select

End Sub

Reply to Helper