Excel VBA Macro to Move a Cell from Column J to Column S
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.
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.
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.
In Excel, open the workbook and select Developer > Visual Basic. If the Developer tab is hidden, enable it in Excel's ribbon settings.
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
Select File > Save As and choose Excel Macro-Enabled Workbook (.xlsm) to retain the VBA code.
Return to the worksheet, select an expense cell in column J, and choose Developer > Macros. Select MoveCellRight and click Run.
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.

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.




