Solved

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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
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 demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

760 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