How to delete a value in cell based on another cell's value using macro

lina91

New Member
Joined
Mar 20, 2017
Messages
1
Greetings,
I am very new to VBA and I would really appreciate your help on the matter! I want to write a code so that it reads the value in column D and if this is blank then it assigns the cell in the same row but on the next column (column E) with blank value. And this process continues until it finds a blank cell in column A. Please I would be very grateful if you could help me in this!:confused::confused::confused::confused:
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Try this:

Code:
Sub Look_Down()
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
    For i = 1 To Lastrow
        If Cells(i, "D").Value = "" Then Cells(i, "E").Value = ""
    Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Or

Code:
Sub aTest()
    Dim LastRow As Long
    
    LastRow = Cells(Rows.Count, "A").End(xlUp).Row
    With Range("E1:E" & LastRow)
        .Value = Evaluate("=IF($D$1:$D$" & LastRow & "="""",""""," & .Address & ")")
    End With
End Sub

M.
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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