VBA & Macro Problems

Excel VBA Macro to Move a Cell from Column J to Column S

Phi Hung VoPhi Hung Vo Nov 20, 2026 868 views

Question details

Move a selected expense cell from column J to column S on the same worksheet row, then select the next cell in column J.

Product
Microsoft Excel VBA
Device & OS
not provided
Scenario
The user wants a macro to move one selected expense at a time and advance to the next row.
Observed behavior
The desired result is for the selected cell to be moved to column S and the selection to advance one row in column J.
Before you start

Open the workbook in a version of Excel that supports VBA, and check whether the destination cells in column S already contain data. Save the workbook as an Excel Macro-Enabled Workbook (.xlsm) if you want to keep the macro.

Solution 1Recommended

Use a VBA macro to move the selected cell and advance

Use this macro when you want to move one selected cell from column J to column S on the same row.

The macro uses the first cell of the selection. It stops if that cell is outside column J or is on the last worksheet row, where there is no next row to select.

1
Open the VBA editor

In Excel, open the workbook and select Developer > Visual Basic. If the Developer tab is hidden, enable it in Excel's ribbon settings.

2
Insert the macro

In the VBA editor, select Insert > Module and paste the following code: Sub MoveCellRight() Dim rng As Range Dim ws As Worksheet Dim rngRow As Long If TypeName(Selection) <> "Range" Then Exit Sub Set rng = Selection.Cells(1, 1) Set ws = rng.Worksheet rngRow = rng.Row If rng.Column <> 10 Then MsgBox "Select a cell in column J." Exit Sub End If If rngRow = ws.Rows.Count Then MsgBox "There is no next row to select." Exit Sub End If If Application.CountA(ws.Cells(rngRow, "S")) > 0 Then MsgBox "The destination cell in column S is not empty." Exit Sub End If rng.Cut Destination:=ws.Cells(rngRow, "S") ws.Cells(rngRow + 1, "J").Select End Sub

3
Save the workbook

Select File > Save As and choose Excel Macro-Enabled Workbook (.xlsm) to retain the VBA code.

4
Select a cell and run the macro

Return to the worksheet, select an expense cell in column J, and choose Developer > Macros. Select MoveCellRight and click Run.

Destination check: The macro stops if the destination cell in column S is not empty. It cuts the cell rather than copying only its displayed value.
Free Microsoft Office alternative

Move expense cells with WPS Spreadsheet

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface. Open a compatible Excel workbook and use Cut and Paste to move expense cells; VBA macro availability and compatibility depend on your WPS edition and configuration.

Move individual expense cells between columns with Cut and Paste.Open and work with Microsoft Excel formats such as XLSX and XLS.Use a familiar spreadsheet interface for an easier transition from Excel.Work with a free, lightweight office suite.
microsoft office alternative - wps office

Frequently Asked Questions

What happens if I select more than one cell?

The macro uses the first cell in the selection. Select a single cell in column J before choosing Developer > Macros and running MoveCellRight.

Will the macro overwrite an existing value in column S?

No. This version checks the destination cell and stops with a message if it is not empty. Review or clear that cell before running the macro again.

Why do I need to save the workbook as XLSM?

The XLSM format can retain VBA macros. Use File > Save As and choose Excel Macro-Enabled Workbook to keep the code with the workbook.

Can I run this Excel macro in WPS Spreadsheet?

VBA support depends on the WPS edition and configuration, and Excel macro compatibility is not guaranteed. Check your WPS installation's VBA support, or use Cut and Paste to move the cell manually.