Solved

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

Posted on 2014-01-29
3
199 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

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…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

772 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