Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

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
?
361 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
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…

661 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