[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Macro Help

Posted on 2013-12-04
4
Medium Priority
?
180 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:Farah Mohammed
[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
  • 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 2000 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:Farah Mohammed
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Microsoft has changed the look and feel of Azure AD and Microsoft account sign-in pages so that you will have a more unified look and feel when moving between the two interfaces.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

656 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