Consulting

Results 1 to 4 of 4

Thread: Formatting help

  1. #1

    Formatting help

    Hi folks,

    I have a simple problem which i am trying to resolve using vba. I have data in the form of:

    userA | dataA | dataAA
    <null>| dataA1| dataAA1
    userB | dataB | dataBB
    <null>| dataB1 | dataBB1


    I need to pull the information relating to each user only from the cells C2 and C4 respectively.

    The easiest way i seen to do this, was copy the data and paste it to a sheet where formulas have been applied to represent the data as

    userA | dataA | dataAA
    userA | dataA1| dataAA1
    userB | dataB | dataBB
    userB | dataB1 | dataBB1

    using a simple if loop. However this makes the task still difficult. I would prefer to do it all in VBA if possible!

    Thanks,

    Ger

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Hmm, Is the data already sorted properly, so all you need to do is fill in the user from the value above?


    Option Explicit
    
    Sub Macro1()
    Dim i               As Long
    Dim LastRow         As Long
    LastRow = Range("B65536").End(xlUp).Row
        For i = 2 To LastRow
            If Range("A" & i).Text = "" Then
                Range("A" & i).Value = Range("A" & i - 1).Text
            End If
        Next i
    End Sub

  3. #3
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    You can do this without code.

    1 Select the column with userA, userB etc.

    2 Goto Edit>Goto...Special... and select Blanks.

    3 In the formula bar type =C2 and then press CTRL+ENTER.

  4. #4
    Excellent thanks for your help folks.

    Ger

Posting Permissions

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