Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 -- Message posted from http://www.ExcelForum.com |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 -----Original Message----- 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 - Pikus --- Message posted from http://www.ExcelForum.com/ . |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yes, instead of filling down what was in ColumnA, it
deleted what was in Column B. -----Original Message----- Did you try what I gave you? - Pikus --- Message posted from http://www.ExcelForum.com/ . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Need Help Quick | Excel Discussion (Misc queries) | |||
Quick help | Excel Worksheet Functions | |||
just a quick one | Excel Discussion (Misc queries) | |||
Help quick | Excel Worksheet Functions | |||
Quick one(I think!), LEN & IF | Excel Discussion (Misc queries) |