VBA for selecting blank cells and populating with a value

Hen25

New Member
Joined
Jun 13, 2017
Messages
1
Hi,

I have a large data to analyse from which I want to identify blank cells in column A and populate it with value in adjacent cells from column F. If column F is blank then populate the value from adjacent cell in column K and if column K is also blank then fill 'Check' as the value in cell.

Does anyone know how I can achieve this using a VBA macro for dynamic data? Please help.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
select the entire table and then turn on the autofilter, then filter it by blanks and set the cells equal to column F#

edit: oh nm, u said vba

Rich (BB code):
Sub Hey()
    Dim r, startRow, endRow As Long

    startRow = 2
    endRow = Cells(Rows.Count, "B").End(xlUp).Row 'pick a column that has no blanks

    For r = startRow To endRow
        If IsEmpty(Cells(r, "A")) Then
            If IsEmpty(Cells(r, "F")) Then
                If IsEmpty(Cells(r, "K")) Then
                    Cells(r, "A") = "Check"
                Else
                    Cells(r, "A") = "=K" & r
                End If
            Else
                Cells(r, "A") = "=F" & r
            End If
        End If
    Next r
End Sub
 
Last edited:
Upvote 0
Here is another macro you can try...
Code:
Sub FillBlanksInColumnAFromForK()
  Dim LastRow As Long
  LastRow = Cells.Find("*", , xlValues, , xlRows, xlPrevious).Row
  Range("A1:A" & LastRow) = Evaluate(Replace("IF(A1:A#<>"""",A1:A#,IF(F1:F#<>"""",F1:F#,IF(K1:K#="""",""Check"",K1:K#)))", "#", LastRow))
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top