Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Place text in column cell IF cell is empty AND cell in another column is not

Posted on 2013-01-16
2
Medium Priority
?
364 Views
Last Modified: 2013-01-16
Hi!
I have a spreadsheet I need to insert text into. Column B will always have a date in it. Column D may or may not have text in it. I need a macro that basically does the following:

If Column B <>"", and Column D = "", then insert DPK into Column D's blank cell.

I've looked all over the web and I'm not able to find exactly what I need. Can someone please help?

Thanks!
0
Comment
Question by:McQMom
2 Comments
 
LVL 13

Accepted Solution

by:
Shanan212 earned 2000 total points
ID: 38783826
Sub Macro3()
Dim rRow As Long, i As Long

rRow = ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Offset(0, 0).Row

For i = 2 To rRow
    
    If Range("B" & i).value <> "" And Range("D" & i).value = "" Then
        Range("D" & i).Value = "DPK"
    End If
Next i

End Sub

Open in new window


Assumption: Data starts from row 2
0
 

Author Closing Comment

by:McQMom
ID: 38783837
Perfect! Thanks so much for the fast & accurate macro!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question