Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variable Range & Sorting Macro
I'm new to VBA & need to create a macro that can find the row with "Lou" &
move that row to the top of the data table. The hitch is the data table postion & the number of rows vary from day to day. The example table below Lou is in row 27 but he could be in row 14 or any other row. The data table is contigous but my start on row 1 or row 5. Thanks in advance! David Ca Cb Cc Cd Ce R1 Joe j k l a R2 Sue d f e c R... x x x x R27 Lou i w z o |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variable Range & Sorting Macro
Try this and feedback
Sub Macro() Dim lngRow As Long Dim lngLastRow As Long Dim varTemp lngLastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row For lngRow = 1 To lngLastRow If UCase(Range("A" & lngRow)) = "LOU" Then varTemp = Range("A" & lngRow & ":Z" & lngRow) Rows(lngRow).Delete Rows(1).Insert Range("A1:Z1") = varTemp End If Next End Sub If this post helps click Yes --------------- Jacob Skaria "David127" wrote: I'm new to VBA & need to create a macro that can find the row with "Lou" & move that row to the top of the data table. The hitch is the data table postion & the number of rows vary from day to day. The example table below Lou is in row 27 but he could be in row 14 or any other row. The data table is contigous but my start on row 1 or row 5. Thanks in advance! David Ca Cb Cc Cd Ce R1 Joe j k l a R2 Sue d f e c R... x x x x R27 Lou i w z o |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variable Range & Sorting Macro
Sub MoveNameToTopRow()
myname = InputBox("Enter name to move") Rows(Columns("a").Find(What:=myname, LookIn:=xlValues, LookAt _ :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Row).Cut Rows(2).Insert End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "David127" wrote in message ... I'm new to VBA & need to create a macro that can find the row with "Lou" & move that row to the top of the data table. The hitch is the data table postion & the number of rows vary from day to day. The example table below Lou is in row 27 but he could be in row 14 or any other row. The data table is contigous but my start on row 1 or row 5. Thanks in advance! David Ca Cb Cc Cd Ce R1 Joe j k l a R2 Sue d f e c R... x x x x R27 Lou i w z o |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Range used in a macro needs to be variable | Excel Worksheet Functions | |||
Macro to copy a specified range to a variable range | Excel Programming | |||
variable range in a macro | Excel Discussion (Misc queries) | |||
Is it possible to set a variable range in a macro? | About this forum | |||
Sorting multiple range using a macro | Excel Programming |