HERE ARE SOME USEFUL CODE FOR YOU
Golden Web Tools
EXCEL VBA · PROFESSIONAL SUITE
Auto Adjust R/C
' AutoFit Columns & Rows
Columns("A:F").AutoFit
Rows("2:10").AutoFit
' Entire sheet auto adjust
Cells.EntireColumn.AutoFit
Cells.EntireRow.AutoFit
Ready
Data Entry Form
' VBA UserForm with TextBox, ComboBox
Dim lastRow As Long
lastRow = Range("A" & Rows.Count).End(xlUp).Row + 1
Range("A" & lastRow).Value = txtName.Text
Range("B" & lastRow).Value = txtDept.Text
Range("C" & lastRow).Value = txtAmount.Text
Range("D" & lastRow).Value = cmbCategory.Value
Ready · auto cell adjust
Auto Serial #
' Auto Serial Number in Column A
Range("A2").Value = 1
Range("A3").Value = 2
' Or loop
Dim i As Long
For i = 2 To 100
Range("A" & i).Value = i - 1
Next i
1,2,3,...10 (simulated)
PDF Export
' Export ActiveSheet as PDF
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:="Report_" & Format(Date, "yyyymmdd") & ".pdf", _
Quality:=xlQualityStandard
Click to export
Email (Outlook)
' Send Email via Outlook
Dim OutApp As Object, OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = "user@domain.com"
.Subject = "Report"
.Body = "Please find attached."
.Attachments.Add ActiveWorkbook.FullName
.Send
End With
Ready
Backup Workbook
' Auto Backup Workbook
ActiveWorkbook.SaveCopyAs _
"Backup_" & Format(Now, "yyyymmdd_hhmmss") & ".xlsm"
' Also auto-save original
ActiveWorkbook.Save
Click to backup
Search Data
' Search for value in Column A
Dim found As Range
Set found = Range("A:A").Find(What:="John", LookAt:=xlPart)
If Not found Is Nothing Then
MsgBox "Found at " & found.Address
Else
MsgBox "Not found"
End If
Enter term & search
Attendance System
' Mark Attendance with Timestamp
Dim lastRow As Long
lastRow = Range("A" & Rows.Count).End(xlUp).Row + 1
Range("A" & lastRow).Value = Range("B1").Value ' Name
Range("B" & lastRow).Value = "Present"
Range("C" & lastRow).Value = Now
' Format timestamp
Range("C" & lastRow).NumberFormat = "dd-mmm-yyyy hh:mm:ss"
Ready
Digital Watch
' VBA: Live Clock with OnTime
Sub UpdateClock()
Range("A1").Value = Format(Now, "hh:mm:ss")
Application.OnTime Now + TimeValue("00:00:01"), "UpdateClock"
End Sub
' Call UpdateClock to start
00:00:00
₹ Rupee Converter
' Convert Number to Indian Rupees (Text)
Function IndianRupee(amt As Double) As String
Dim crore, lakh, thousand, remainder
' Custom logic for Crore, Lakh, Thousand
' Returns "Rupees ... Only"
End Function
Rupees ...
Golden Web Tools · Professional VBA Suite · Click to copy any code