Excel Useful Macro
Excel Useful Macro
2. Click Developer>Visual Basic or press Alt + F11, a new Microsoft Visual Basic
for applications window will be displayed, click Insert>Module, and input the following
code into the Module:
VBA: Remove time from date.
Sub ConvertDates()
'Updateby20140529
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address,
Type:=8)
For Each Rng In WorkRng
Rng.Value = VBA.Int(Rng.Value)
Next
WorkRng.NumberFormat = "dd/mm/yyyy"
End Sub
3. Then click button to run the code. And a dialog pops out for selecting a range to remove
the time from date. See screenshot:
Click OK, and all of the time in selection have been deleted and the date format also have been
set.
If Application.CountA(Rows(iCounter).EntireRow) = 0 Then
Rows(iCounter).Delete
End If
Next iCounter
If Application.CountA(Columns(iCounter).EntireColumn) = 0 Then
Columns(iCounter).Delete
End If
Next iCounter
End Sub
Case Is = vbYes
ThisWorkbook.Save
Case Is = vbCancel
Exit Sub
End Select
MyCell = Trim(MyCell)
End If
Next MyCell
End Sub
Make QR Code
On Error GoTo 0
ActibeSheet.Pictures.Insert(URL).Select
With Selection.ShapeRange(1)
.PictureFormat.CropLeft = 15
.PictureFormat.CropRight = 15
.PictureFormat.CropTop = 15
.PictureFormat.CropBottom = 15
.Left = MyCell.Left + 25
.Top = MyCell.Top + 5
End With
End Function
End Sub