Quick VB Help

  • Thread starter Thread starter April
  • Start date Start date
A

April

I need help writing some vb script.... I know that it is
not that hard, I am just having a brain freeze today and
need help. Here is what I have... In Column A, every
couple of rows I have a "Identifier" then a couple of
rows of names (Column B) and I need to write code that
will Start at A2 (Or Active Cell) and Do a Select
(xlDown), Offset (-1,0) (Up one Row) and CopyDown, then
select then next identifier and do it again until the
end. For example, Cell A2 to A4 will copy down what is in
A2, A5 to A26 will copy down what is on A5, A27 to A47
will copy down what is in A27.

Thanks, April
 
Try this:

lrow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count
For x = 2 To lrow
If Worksheets(1).Cells(x, 1).Value <> "" Then
nam = Worksheets(1).Cells(x, 2).Value
y = x
Do
y = y + 1
Loop Until Worksheets(1).Cells(y + 1, 1).Value <> "" Or _
y = lrow
For z = x + 1 To y
Worksheets(1).Cells(z, 2).Value = nam
Next z
End If
Next x

- Piku
 
I have this:

Do
ActiveCell.Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.Offset(-1, 0)).Select
Selection.FillDown
Selection.End(xlDown).Select

Loop

The only problem is the offset(-1,0) is not working
right. Say it has A5:A10 Selected, instead of changing
it to A5:A9 with the Offset(-1,0) it is changing it to
A4:A10 or A5:A11, how do I get it to offset up one row
(From the bottom of the select and not from the top).

April
 
Back
Top