DEV Community

Andrews
Andrews

Posted on • Originally published at geekexcel.com on

Remove Characters at the Start using Macros (VBA) in Excel 365!!

To remove characters at the start of the input values, you can use VBA & Macros ** in Excel Office 365. With the help of Macros, you can easily achieve this task. In this article, we are going to learn the steps to **remove characters at the start using Macros (VBA) in Excel Office 365.

Steps to Remove Characters at the Start using Macros:

Follow the below instructions to delete characters at the start of the input values in the Excel worksheet.

  • In the following image, you can see the input range from cell B2:B6. We are going to remove the first two characters of these input values.

Input range
Input range

  • On the Developer Tab, select the Visual Basic option under the Code section.

Select Visual Basic option
Select the Visual Basic option

  • Then you need to copy and paste the code given below.

VBA code to remove characters using Macros

Sub RemoveCharactersAtTheStart()

Dim range As Range

Dim num As Integer

‘Get the characters

num = InputBox(“Input the number of characters to remove at the start”, “Num of characters”)

For Each range In Selection

‘Use Right to remove the first x characters

range = Right(range, Len(range) – num)

Next range

End Sub

  • You need to save the code by selecting it. Then close the window.

Save the code
Save the code

  • You have to open the sheet containing the data. On the Developer Tab, choose the Macros option in the Code section.

Choose the Macros option
Choose the Macros option

  • You need to make sure that your macro is selected and click the Run button.

Click Run button
Click Run button

  • Now, it will display a dialog box, where you want to enter the number of characters that you want to remove from the input range.

Click the OK button
Click the OK button

  • As a result, you will see that the first two characters are removed from the input values as shown in the below screenshot.

Output
Output

Verdict:

In the above article, we have learned the clear-cut steps to remove characters at the start using Macros (VBA) in Excel Office 365. Give your worthwhile feedback in the below comment section. Thanks for visiting Geek Excel. Keep Learning!

Keep Reading:

Top comments (0)