Solved

Macro Help

Posted on 2013-12-04
4
173 Views
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
Book2.xlsx
0
Comment
Question by:squirrelzan
  • 3
4 Comments
 
LVL 33

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.

Thanks
Rob H
0
 
LVL 33

Accepted Solution

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

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

    Columns("C:D").Select
    Selection.Delete Shift:=xlToLeft
    Rows("2:2").Select
    Selection.Delete Shift:=xlUp
    Range("A2").Select
Application.Calculation = xlCalculationAutomatic

Open in new window


Thanks
Rob H
0
 

Author Closing Comment

by:squirrelzan
ID: 39696037
This worked perfectly. Thank you
0
 
LVL 33

Expert Comment

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

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

Thanks
Rob H
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
copy same as above data 18 39
save excel in the same active file's folder. 8 24
Excel Sheet Data Finding 14 18
VBA working with shapes 6 11
Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
Outlook Free & Paid Tools
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

828 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