Macro Help

Posted on 2013-12-04
Medium Priority
Last Modified: 2013-12-04
I have the attached spreadsheet which has about 300 lines.
I need to have the guest names under the employee names, basically leaving me with two columns instead of four. However, for example, guest F1 needs to be under employee F1 and guest L1 needs to be under employee L1 and so on.

I tried doing a macro myself but it seems to be stuck on cell c2. I have 300 lines in my original file and thus am not excited of doing it manually.

All help is appreciated.

Thank you
Question by:Farah Mohammed
  • 3
LVL 35

Expert Comment

by:Rob Henson
ID: 39695874
Can you upload the code you tried and we can maybe point out the error?

The way I am thinking of approaching is to insert a row between each employee line, then copy the guest columns and paste into the employee columns selecting Paste Special and SKip Blanks.

This can be automated as required.

Rob H
LVL 35

Accepted Solution

Rob Henson earned 2000 total points
ID: 39695935
Try the code below:
Sub InsertRows()

Application.Calculation = xlCalculationManual
Do Until ActiveCell.Value = ""
    ActiveCell.Offset(1, 0).Select
    ActiveCell.Offset(1, 0).Select
    LR = ActiveCell.Row
    Range("C2:D" & LR).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=True, Transpose:=False

    Selection.Delete Shift:=xlToLeft
    Selection.Delete Shift:=xlUp
Application.Calculation = xlCalculationAutomatic

Open in new window

Rob H

Author Closing Comment

by:Farah Mohammed
ID: 39696037
This worked perfectly. Thank you
LVL 35

Expert Comment

by:Rob Henson
ID: 39696115
Glad to be of assistance.

Don't forget it assumes only one line per employee.

Rob H

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

In this article, I will demonstrate that how to do a PST migration from Exchange Server to Office 365. This method allows importing one single PST, or multiple PST's at once.
I tried to use the SharePoint app to Import a Spreadsheet and import an Excel sheet into a Team site made in SharePoint 2016. But that just resulted in getting an error message 'Unknown Error'...
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

607 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