Mehedi Hassan

About author

Mehedi Hassan, having earned a BSc in Naval Architecture & Engineering from Bangladesh University of Engineering and Technology, functions as an Excel & VBA Content Developer at ExcelDemy. His deep interest in research and innovation aligns seamlessly with his fervor for Excel. In this role, Mehedi not only skillfully addresses challenging issues but also exhibits enthusiasm and expertise in gracefully navigating intricate situations, emphasizing his unwavering dedication to consistently delivering outstanding content. His interests are Advanced Excel, Data Analysis, Charts & Dashboards, Power Query, and Excel VBA. Apart from creating Excel tutorials, he is interested in Data Analysis with MS Excel, AutoCAD, Rhinoceros, ANSYS, Adobe Illustrator, Adobe Premiere Pro, and Report Writing.

Designation

Excel & VBA Content Developer at ExcelDemy in SOFTEKO.

Lives in

Dhaka, Bangladesh.

Education

B.Sc. in Naval Architecture & Marine Engineering, BUET.

Expertise

Microsoft Suite, AutoCAD, Rhinoceros, ANSYS, Adobe Illustrator, Adobe Premiere Pro

Experience

  • Technical Content Writing
  • Undergraduate Projects
    • Design of an Inland Cargo Vessel
    • Hydrodynamic Performance Analysis of a Hydrofoil Supported High Speed Vessel

Latest Posts From Mehedi Hassan

0
Excel Date Functions – A Complete Guide

This is an overview. . Download Practice Workbook Download the workbook here. Excel Date Functions.xlsx 1 - Insert Dates Using ...

0
Excel AutoFilter – A Complete Guide

This is an overview. Download Practice Workbook Download this file to practice. Excel AutoFilter.xlsx How to Enable the AutoFilter ...

0
How to Insert and Use Excel Form Control

       Turning On the Developer Tab Go to the File tab in the ribbon. Click on it, and Excel will show you the Backstage view. ...

0
Suffix and Prefix in Excel: A Complete Guide: 5 Methods

Method 1 - Using Ampersand Operator Add prefix, select cell D5 write this formula, and press Enter. =B5&" "&C5 Use Fill Handle (+) to ...

0
How to Use Subscript and Superscript in Excel: A Complete Guide

Understanding Subscript and Superscript In mathematics, computing, and typography: Subscript: A character or symbol written in the bottom-right section ...

0
How to Apply Excel Text Format: 5 Methods

Method 1 - Format Numbers in Excel Select cell C5 to write this formula and press Enter. =TEXT(B5,"$###,###.00") You can see that other ...

0
How to Make and Use a ColorIndex Value Chart in Excel

Below is an image showing each color palette in ColorIndex and their RGB value. Predefined Names of an Excel VBA ColorIndex There are 8 predefined ...

0
How to Use Excel VBA to Run a Macro When the Cell Value Changes – 3 Examples

  Overview:   Example 1. Running a Macro When a Specific Cell Value Changes The dataset showcases students and their marks. A ...

0
How to Use Excel VBA to Add a Comment to a Cell – 3 Examples

This is an overview.   If you are new to Microsoft Visual Basic Application, read How to Write VBA Code in Excel. Example 1 - Add Comment ...

0
Excel VBA to Call Sub with Parameters (3 Suitable Examples)

If you want to learn Visual Basic for Applications (Excel VBA), one of the most important concepts to know is Subroutines with parameters and how to call them. ...

0
How to Use the Excel VBA Textbox to Format Dates (4 Methods)

When working with UserForms in Excel VBA, it is often necessary to format the date values displayed in TextBox controls for a better user experience. ...

0
How to Reference a Named Range in Another Sheet in Excel (3 Examples)

  What Is Named Range in Excel and How to Create It Names frequently refer to individuals, things, and locations in daily life. For instance, you would ...

0
How to Use Excel SUMIF to Sum Values Greater Than 0 (3 Methods)

Introduction to the SUMIF Function in Excel Microsoft Excel includes a built-in function called SUMIF, which allows you to add up values within a specified ...

Browsing All Comments By: Mehedi Hassan
  1. Hello Bart,
    Thank you for reaching out. Your problem has a very simple solution. Instead of writing the code in a Sub Procedure, create an Event, Worksheet_SelectionChange in each of your Worksheet and simply paste your code.
    VBA Code for Event
    Do the same thing in every worksheet except the Index worksheet and modify the code as per your requirements. In this way, you don’t have to run the code every time.
    Here’s the modified code:

     Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        Dim mVCount As Integer
        Dim mHCount As Integer
        Dim mVBreak As VPageBreak
        Dim mHBreak As HPageBreak
        Dim mNumPage As Integer
        mHCount = 1
        mVCount = 1
        If ActiveSheet.PageSetup.Order = xlDownThenOver Then
            mHCount = ActiveSheet.HPageBreaks.Count + 1
        Else
            mVCount = ActiveSheet.VPageBreaks.Count + 1
        End If
        mNumPage = 1
        For Each mVBreak In ActiveSheet.VPageBreaks
            If mVBreak.Location.Column > ActiveCell.Column Then Exit For
            mNumPage = mNumPage + mHCount
        Next
        For Each mHBreak In ActiveSheet.HPageBreaks
            If mHBreak.Location.Row > ActiveCell.Row Then Exit For
            mNumPage = mNumPage + mVCount
        Next
        ThisWorkbook.Worksheets("Worksheet 1").Range("I2").Value = "Page " & mNumPage & " of " & Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
        ThisWorkbook.Worksheets("Worksheet 3").Range("C5").Value = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
    End Sub

    Here is the result:
    Results of the code
    Hopefully, this will solve your problem.

    Regards
    Hassan Shuvo || Exceldemy

  2. Hello Jaye,
    Hope you are doing well.
    #NAME error appears when you have a syntax problem in your formula. There shouldn’t be any #NAME error appearance when you add a new sheet to your workbook. We have checked out the VBA and the function and didn’t find any problem.

    We recommend you share your file or at least a Screenshot of the problem with us and we will get back to you about a solution.

    Regards
    Hassan Shuvo || ExcelDemy

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo