SWAP Values Using Macros in Excel:
In this article, we are going to see how to Swap Values using Macros in Excel Office 365 with an example. Let’s get into this article!! Get an official version of MS Excel from the following link: https://www.microsoft.com/en-in/microsoft-365/excel
Steps to Swap Values Using Macros in Excel:
To swap two values in the Excel spreadsheet with the help of Macros, do as below instructions.
- First, you need to enter two numbers that you want to swap.
- On the Developer Tab, click the Insert option, then select the button icon under the ActiveX controls section.
- Now, you need to drag and select the cell anywhere in the spreadsheet to insert the button.
- You need to right-click on the button and select the View Code option from the menu.
- You have to enter the below code and close the window.
VBA Code for SWAP Values
Dim container As Double
container = Range(“A8”).Value
Range(“A8”).Value = Range(“B8”).Value
Range(“B8”).Value = container
- Now, you need to check that the Design Mode is selected or not. If is selected, you have to deselect it.
- You have to click the created button and see that the values are swapped.
From the above steps, you can clearly understand how to swap two numbers using Macros.
You can find the working of above Macro in the below video.
<!--[if lt IE 9]>document.createElement('video');<![endif]-->
Wind-Up:
In this article, you can learn the steps to Swap Values using Macros in Excel Office 365 with an example. Drop your feedback in the comment section. Thanks for visiting Geek Excel. Keep Learning!!
Top comments (0)