Solved

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

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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,…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

717 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