Related:
- Move cells to the next column
- Excel column number - Guide
- How to delete a column in word - Guide
- Tweetdeck expand column - Guide
- The following excel image has a vba program (see below). what will be the result after the program is executed? any cells not displayed are currently empty, and any cells with numbers are formatted numeric. sub afdo a=0 lastrow = cels(rows. count, 1). end(xdup). row for i =14 to lastrow step 2 a=a cellsii. 5) value next cells(lastrow 2, 1) value = "the sum - Guide
- Vba column ✓ - Excel Forum
1 response
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
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