How to Autofill in Your Worksheet using Excel VBA?

In this post, you’ll learn how you can autofill in your worksheet programmatically using Excel VBA.

How to Autofill in Your Worksheet using Excel VBA?

Here’s a below code snippet that demonstrates how you can do this. It takes the autofill data range from A1 and A2 and autofills the cells from A1 to A10.

Just enter the value 1 and 2 in cells A1 and A2 respectively and call this function to see the autofill in action.

Sub AutoFill()

    'DP - VBA to demonstrate how to auto fill when you enter values in the cell A1 and A2.
    
    Dim InputSelection As Range
    
    Dim AutoFillRange As Range
    
    
    Set InputSelection = Sheet1.Range("A1:A2")
    
    Set AutoFillRange = Sheet1.Range("A1:A10")
    
    
    InputSelection.AutoFill Destination:=AutoFillRange
End Sub
How to Autofill in Your Worksheet using Excel VBA?

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this article, you will learn about the SKEW.P function, the formula syntax and usage of the function in Microsoft...
In this article, you will learn about the SKEW function, the formula syntax and usage of the function in Microsoft...
In this article, you will learn about the RANK.EQ function, the formula syntax and usage of the function in Microsoft...
  • Excel
  • November 23, 2021