PDA

View Full Version : [SOLVED] Formatting help



gersemale
07-04-2005, 09:19 AM
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

Jacob Hilderbrand
07-04-2005, 11:08 AM
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

Norie
07-04-2005, 11:22 AM
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.

gersemale
07-05-2005, 05:39 AM
Excellent thanks for your help folks.

Ger