Solved

Macro Help

Posted on 2013-12-04
4
169 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 31

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 31

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 31

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
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.

708 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

17 Experts available now in Live!

Get 1:1 Help Now