# Excel Tutorials | Macros Code

### Remove Decimals from Numbers

Sub removeDecimals() Dim lnumber As Double Dim lResult As Long Dim rng As Range For Each rng In Selection rng.Value = Int(rng) rng.NumberFormat = “0”

### Remove the Apostrophe from a Number

Sub removeApostrophes() Selection.Value = Selection.Value End Sub VBA Macro Code to Remove the Apostrophe from a Number in Excel If you have numeric data where

### Add a Number in all the Numbers

Sub addNumber() Dim rng As Range Dim i As Integer i = InputBox(“Enter number to multiple”, “Input Required”) For Each rng In Selection If WorksheetFunction.IsNumber(rng)

### Remove Time from Date

Sub removeTime() Dim Rng As Range For Each Rng In Selection If IsDate(Rng) = True Then Rng.Value = VBA.Int(Rng.Value) End If Next Selection.NumberFormat = “dd-mmm-yy”

### Multiply all the Values by a Number

Sub addNumber() Dim rng As Range Dim i As Integer i = InputBox(“Enter number to multiple”, “Input Required”) For Each rng In Selection If WorksheetFunction.IsNumber(rng)

### Convert to Lower Case

Sub convertLowerCase() Dim Rng As Range For Each Rng In Selection If Application.WorksheetFunction.IsText(Rng) Then Rng.Value= LCase(Rng) End If Next End Sub This code will help

### Remove a Character from Selection

Sub removeChar() Dim Rng As Range Dim rc As String rc = InputBox(“Character(s) to Replace”, “Enter Value”) For Each Rng In Selection Selection.Replace What:=rc, Replacement:=””

### Convert to Proper Case

Sub convertProperCase() Dim Rng As Range For Each Rng In Selection If WorksheetFunction.IsText(Rng) Then Rng.Value = WorksheetFunction.Proper(Rng.Value) End If Next End Sub And this code

### Convert to Upper Case

Sub convertUpperCase() Dim Rng As Range For Each Rng In Selection If Application.WorksheetFunction.IsText(Rng) Then Rng.Value = UCase(Rng) End If Next End Sub VBA Macro code

### Convert Date into Year

Sub date2year() Dim tempCell As Range Selection.Value = Selection.Value For Each tempCell In Selection If IsDate(tempCell) = True Then With tempCell .Value = Year(tempCell) .NumberFormat