?
Solved

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

Posted on 2014-01-29
3
Medium Priority
?
220 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
[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
3 Comments
 
LVL 46

Accepted Solution

by:
aikimark earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

762 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