Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default if condition true then move a whole row to another sheet

I have an excel workbook which contains 3 worksheets - Order, Pending &
Complete - each sheet is exactly the same layout and header row
i would like to automate the following:
if on the Order sheet "Complete" is entered in column H then move whole row
to end of Complete sheet
or if 'Pending' is entered in column H then move whole row to Pending sheet

i would be grateful if anyone could help please and would prefer if there
wasnt any formulae on the actual sheets as due to the way stuff is entered
on the Order sheet any formulae could easily be overwritten

thankyou
xx Gran2


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default if condition true then move a whole row to another sheet

Hi

Place a button on the Order spreadsheet (to get button view toolbars
control toolbox and then draw a button where you want)

Now click Tools Macro visual basic editor

Double click the Order sheet and copy and paste the code below, Ive tested it
and it works fine, any problems email me and I shall send you my test which
works :-)



Sub commandbutton1_click()


lastroworder = Worksheets("Order").UsedRange.Row _
+ Worksheets("Order").UsedRange.Rows.Count - 1

lastrowpen = Worksheets("Pending").UsedRange.Row _
+ Worksheets("Pending").UsedRange.Rows.Count - 1

lastrowcom = Worksheets("Complete").UsedRange.Row _
+ Worksheets("Complete").UsedRange.Rows.Count - 1

For pen = 1 To lastroworder
If UCase(Worksheets("Order").Cells _
(pen, 8).Value) = UCase("Pending") Then
Worksheets("Pending").Range("A" & _
lastrowpen + 1 & ":H" & lastrowpen + 1).Value = _
Worksheets("Order").Range("A" & pen & ":H" & pen).Value
Rows(pen).ClearContents
lastrowpen = lastrowpen + 1
End If
Next pen

For com = 1 To lastroworder
If UCase(Worksheets("Order").Cells _
(com, 8).Value) = UCase("Complete") Then
Worksheets("Complete").Range("A" & _
lastrowcom + 1 & ":H" & lastrowcom + 1).Value = _
Worksheets("Order").Range("A" & com & ":H" & com).Value
Rows(com).ClearContents
lastrowcom = lastrowcom + 1
End If
Next com


For del = lastroworder To 1 Step -1
If Sheets("Order").Cells(del, 8).Value = "" Then
Rows(del).Delete
End If
Next del

End Sub

--
Message posted via
http://www.officekb.com
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
How to find first row where condition is true? WhatsUp31415 Excel Discussion (Misc queries) 6 May 21st 09 12:11 PM
TRUE condition??? pmguerra Excel Discussion (Misc queries) 2 June 5th 06 04:27 PM
if condition is true than send info to another work sheet jwpmann Excel Programming 1 August 7th 05 10:00 AM
Save If Condition is true igorek Excel Programming 2 July 12th 05 11:19 PM
when condition is true, move row to end of different sheet Gran Excel Programming 1 March 8th 05 02:31 PM


All times are GMT +1. The time now is 06:54 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"