Forum Discussion

Thomas2170's avatar
Thomas2170
Copper Contributor
May 18, 2020

Re: Use VBA to Autofill a Row until the end of the number of data in another row

Thanks@Haytham,

But i m facing one issue that it is autofilling as 1 I want it be filled in series. Like 1,2,3 and so on

2 Replies

  • Haytham Amairah's avatar
    Haytham Amairah
    Silver Contributor

    Thomas2170

     

    Hi,

     

    Please use this below instead, and tell me what you think.

    Sub AutoFillToRight()
        Dim lastCellFromRight As String
        ActiveCell.Select
    
        lastCellFromRight = Selection.End(xlDown).End(xlToRight).Offset(-1, 0).Address
        
        If lastCellFromRight = "$XFD$1048575" Or lastCellFromRight = "$IV$65535" Then Exit Sub
        
        Range(ActiveCell.Address, lastCellFromRight).FillUp
        Range(lastCellFromRight).Select
    End Sub

     

    Regards

  • Thomas2170's avatar
    Thomas2170
    Copper Contributor
    Please also could you help me with the same for autofill ing down in series depending on data in the coloumn beside it