Solved

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

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

708 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

13 Experts available now in Live!

Get 1:1 Help Now