Results 1 to 4 of 4

Basic Macro query

Threaded View

  1. #1
    Registered User
    Join Date
    09-24-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    1

    Basic Macro query

    Hello, I am new to VB and I’m trying to use a macro to sort out my Excel text data. Here is an example of my problem.

    ColA Col B
    P x1
    P x2
    P x3
    B y1
    B y2
    C z1
    C z2
    C z3

    I am trying to create a macro to delete repetitions in Column A (Col A) but at the same time put data from Column B (x1, x2 and x3) into different columns under the same Row 1. I’m trying to get my data to look like:

    Col A Col B Col C Col D
    P x1 x2 x3
    B y1 y2
    C z1 z2 z3

    Due to the large amount of data, I am unable to manually do this and would hence like to automate the process. I came up with some code, but there are errors in it. I would really be grateful if I could get some help on this.

    Sub LoopRange()

    x = ActiveCell.Row
    y = x + 1

    Do While Cells(x, 1).Value <> ""
    Do While Cells(y, 1).Value <> ""

    If (Cells(x, 1).Value = Cells(y, 1).Value) Then Range("B1").Offset(0, 1).Select And Cells(y, 1).EntireRow.Delete

    Else
    y = y + 1
    End If
    Loop

    x = x + 1
    y = y + 1
    Loop

    End Sub

    There is a good chance that this code is nothing but lines of garbage. I really hope someone can help me structure it to meet the requirements of the format mentioned above.

    Thank you.
    Last edited by beginner123; 09-24-2009 at 03:48 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1