Solved

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

Posted on 2013-01-16
2
333 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 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I comeā€¦
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

813 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now