Excel VBA Tutor

Excel VBA Tutor

Share

Microsoft Excel: Quick tips and tricks

18/05/2023

How to save workbook as a PDF using VBA.

Sub SaveWorkbookAsPDF()
Dim FilePath As String
Dim FileName As String

' Set the file path and name for the PDF file
FilePath = "C:\Your\Desired\Path\" ' Specify the desired file path
FileName = "YourFileName.pdf" ' Specify the desired file name

' Save the workbook as a PDF file
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=FilePath & FileName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False

' Display a message when the PDF file is saved
MsgBox "Workbook saved as PDF file: " & FilePath & FileName, vbInformation
End Sub

27/01/2020

Need to automatically update the chart data sheet in PowerPoint chart using excel vba.

11/09/2019

How to add data onto the name range dynamically.

Sub dynamicnamevalueadd()
Dim i As Integer
Dim lastrow As Long

'This will provide the lastrowcount
lastrow = Range("A" & Rows.Count).End(xlUp).Row

'Using resize will help to increase the name range
With Range("Data")
Resize(lastrow).Name = "Data"
End With
End Sub

21/04/2019

Excel Sheet sort using bubble sort
Sub Sheet_Sort()
Dim i As Integer, j As Integer
Dim sheetname() As String
Dim ws As Worksheet
j = 1
i = Sheets.Count
ReDim sheetname(1 To i)
For Each ws In Worksheets
sheetname(j) = ws.Name
j = j + 1
Next
Call bubblesort(sheetname)
j = 1
For Each ws In Worksheets
ActiveWorkbook.Sheets(sheetname(j)).Move before:=Sheets(j)
j = j + 1
Next
End Sub

Sub bubblesort(ss() As String)
For i = LBound(ss) To UBound(ss) - 1
For j = i + 1 To UBound(ss)
If ss(i) > ss(j) Then
temp = ss(j)
ss(j) = ss(i)
ss(i) = temp
End If
Next
Next
End Sub

22/09/2018

Feedback... :) :)

10/04/2018

To check whether a number is a palindrome or not first we reverse it and then compare the number obtained with the original number, if both are same then the number is palindrome otherwise not. Palindrome string program.Like 16461

Below is the program for your reference.

Sub Check_palindrome()
Dim ss As String
ss = Val(Range("a1"))
For i = Len(ss) To 1 Step -1
mm = mm & Mid(ss, i, 1)
Next
If ss = mm Then
MsgBox "No is palindrome"
Else
MsgBox "No is not palindrome"
End If
End Sub

30/01/2018

Advance filter in excel data tab.

Photos 27/01/2018

Excel Table tutorial.

Photos 01/08/2016

Home Loan Calculator by using PMT goal seek function in Excel.

Photos 17/01/2016

Sub extracting_hyperlinks()
Dim i As Integer
Dim j As Integer
For i = 1 To 3
Cells(i, 2).Value = Cells(i, 1).Hyperlinks(1).Address
Next
End Sub

Want your school to be the top-listed School/college in Bangalore?

Click here to claim your Sponsored Listing.

Location

Category

Telephone

Address


Bangalore
560066