Solved

What code would I use to transfer data between columns in the excel file described below?

Posted on 2014-01-29
3
190 Views
Last Modified: 2014-01-30
I have a very large excel spread sheet where I need to transfer text from Column B to Column D in the case where there is no date (blank cell or Null) in the same row in column D and there is text in column D (same row).  Please see the attached excel spread sheet which contains two sheets -  Example and desired result. The rows where the text from column B should be copied and pasted in the same row in Column D are highlighted in the sample sheet . Thanks
EEtest.xlsx
0
Comment
Question by:PDSWSS
  • 2
3 Comments
 
LVL 45

Accepted Solution

by:
aikimark earned 500 total points
ID: 39820828
In order to run this, you will need to use an xlsm workbook.
Option Explicit

Public Sub Q_28351724()
    Dim rng As Range
    Dim wks As Worksheet
    Set wks = ActiveSheet   'or specific worksheet
    Application.ScreenUpdating = False
    For Each rng In wks.Range(wks.Cells(2, 2), wks.Cells(wks.Cells.SpecialCells(xlCellTypeLastCell).Row, 2))
        If Len(rng.Value) <> 0 And Not (IsDate(rng.Offset(0, 2).Value)) Then
            rng.Offset(0, 2).Value = rng.Value
        End If
    Next
    Application.ScreenUpdating = True
End Sub

Open in new window

0
 

Author Comment

by:PDSWSS
ID: 39820900
aikimark

Great job!  Could you annotate the code so I can understand what the different lines of code
do. Thank you very much.
0
 

Author Closing Comment

by:PDSWSS
ID: 39820905
Exactly what I was looking for. Thank you very much.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

912 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

18 Experts available now in Live!

Get 1:1 Help Now