How to Move Last Word to Next Adjacent Cell?


Learning how to use Excel's robust features can dramatically improve your productivity and data organisation, whether you're a novice or a seasoned user. In this article, we'll walk you through each step of an effective technique to move the last word from one cell to the one next to it.

We will presume that you are familiar with Microsoft Excel and its foundational ideas throughout this lesson. But don't worry if you're just getting started with the software! To help you understand each step clearly, we will give you clear instructions and illustrated examples.

Move Last Word to Next Adjacent Cell

Here, we will first create a VBA module and then run it to complete the task. So let us see a simple process to see how you can move the last word to the next adjacent cell in Excel.

Step 1

Consider an Excel sheet where you have a list of strings.

First, right-click on the sheet name and select View code to open the VBA application.

Right Click > View Code.

Step 2

Then click on Insert and select Module, then copy the below code into the text box.

Insert > Module > Copy.

Code

Sub splitlastword()
   Dim xCell As Range
   Dim xStr As String
   Dim xAddress As String
   Dim xRg As Range
   On Error Resume Next
   xAddress = ActiveWindow.RangeSelection.Address
   Set xRg = Application.InputBox("Please selec the text cells:", "Move Last Cell", xAddress, , , , , 8)
   If xRg Is Nothing Then Exit Sub
   If xRg.Columns.Count > 1 Then
      MsgBox "Only one column in the seleted range", vbInformation, "Move Last Cell"
      Exit Sub
   End If
   For Each xCell In xRg
      xStr = Trim(xCell.Value)
      xCell.Offset(0, 1) = Mid(xStr, InStrRev(xStr, " "))
      xCell.Value = Left(xStr, InStrRev(xStr, " "))
   Next
End Sub

Step 3

Then click F5 to run the module. Then select the range of cells and click OK.

F5 > Select Cells > Ok.

This is how you can move the last word to the next adjacent cell in Excel.

Conclusion

In this tutorial, we used a simple example to demonstrate how you can move the last word to the next adjacent cell in Excel to highlight a particular set of data.

Updated on: 24-Aug-2023

99 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements