(Solved) – How to find the column name of first empty cell in a row?

(solved)-–-how-to-find-the-column-name-of-first-empty-cell-in-a-row?

This is my sample data. my data looks like this

I want to select the first empty cell in row 1, which is column D, and use this columnname to fill data using range function. In simple words, i want to fill data in D2:D3. I wrote a code like this- but this writes data to C2:C3 not D2:D3.

    Dim row As Long
    Dim lastrow As Long
    Dim lastcolumn As Variant

    lastcolumn = Split(Workbooks("Release.xlsm").Worksheets("Sheet4").Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Cells.Address(1, 0), "$")(0)
lastrow = Workbooks("Release3.xlsm").Worksheets("Sheet4").Cells(Rows.Count, 1).End(xlUp).row
    For row = 2 To lastrow

        Range(lastcolumn & row).Value = "success"

    Next

Leave a Reply

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