Excel Guides

Swapping Two Strings in Excel

To swap two strings in Excel, first select the cell containing the string you want to swap. Then, press and hold the Ctrl key on your keyboard and press the t key. This will open the Swap dialog box. In the Swap dialog box, select the string you want to swap in the first drop-down menu and select the string you want to swap in the second drop-down menu. Finally, click the Swap button.

You can also swap two strings by using a macro. To do this, first open the Visual Basic Editor by pressing Alt + F11. Then, in the Visual Basic Editor, click Insert > Module. This will insert a new module into your workbook. In the new module, paste the following code:

Sub SwapStrings()

Dim str1 As String
Dim str2 As String

str1 = Range("A1").Value
str2 = Range("A2").Value

Range("A1").Value = str2
Range("A2").Value = str1


End Sub

This macro will swap the strings in cells A1 and A2. To use this macro, select cells A1 and A2, then press Alt + F8. In the Macro dialog box, select SwapStrings, then click Run. The strings in cells A1 and A2 will be swapped.

Move beyond 

Excel

Get started with Causal today.
Build models effortlessly, connect them directly to your data, and share them with interactive dashboards and beautiful visuals.