Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Range used in a macro needs to be variable DaveP Excel Worksheet Functions 3 November 4th 05 03:23 PM
Macro to copy a specified range to a variable range SWT Excel Programming 4 October 21st 05 08:24 PM
variable range in a macro AMK Excel Discussion (Misc queries) 3 July 6th 05 09:32 AM
Is it possible to set a variable range in a macro? Mary About this forum 0 June 12th 05 06:26 PM
Sorting multiple range using a macro onlinepredator Excel Programming 4 August 14th 04 12:52 PM


All times are GMT +1. The time now is 08:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"