Search : in
By :

Copy rows based on a condition

Last answer on Sep 10, 2009 7:01:42 pm BST Blossom83, on Oct 14, 2008 5:53:56 pm BST 
 Report this message to moderators

Hi

How can I have excel copy the entire row of data from worksheet Employee Inventory to another worksheet called EEs if column Q contains TERM. I've tried almost everything but nothing is working. Please help!

Configuration: Windows 2003
Internet Explorer 6.0

Best answers for « Copy rows based on a condition » in :
Basic MS-Dos commands ShowBasic MS-Dos commands Intro The command prompts: Intro Here is a list of basic commands that you can use in a DOS prompt (e.g. a using a boot disk). To have additional information about these commands, type /? after entering the...
Colouring cells on conditions ShowColouring cells on conditions There are many pratical functions under Excel which is not commonly used. Example: If you wish a cell automatically turns red (or other formatting border, frame etc) under one condition: a result, a...
Copy an entire partition on Vista ShowCopy an entire partition on Vista Issue Solution Issue It is possible to copy the entire partition on your hard drive with the DVD of vista. It is very useful if you want to change your hard drive in order to restore all data....
Download CopyTrans Suite ShowCopyTrans Suite is a set of practical tools for your Ipod or Iphone. It contains: · CopyTrans v2.37 · CopyTrans Photo v2.21 · iLibs v1.13 · iCloner v1.07 · CopyTrans Doctor v1.015 · CopyTrans Manager v0.720 · SyncGuardian...
Spreadsheet - Formulas ShowIntroduction to Formulas The main use of a spreadsheet is to automate calculations, which means using cells to perform operations based on values in other cells. The spreadsheet recalculates all the values each time a change is made to the value of...
Spreadsheets - Conditional expressions ShowWhat is a Conditional Structure? Conditional structures are instructions that allow to test if a condition is true or not. Conditional structures may be associated together. To successfully execute these tests using logical functions, spreadsheets...
Base64 encoding ShowBase64 encoding The concept of Base64 encoding entails using US-ASCII (non-accented) characters to encode any sort of data in 8-bit form. Email protocols were originally designed to send messages in plain text only. But as email systems vary...

1

Helper, on Feb 2, 2009 8:54:15 pm GMT
  • +9

Assumptions for this code:
1. Employee Inventory sheet has heading in row one so it will start checking the data in row 2.
2. Column Q does not have any empty cells.
3. EEs sheet will have headings in row one so the data will start copying in row 2.

Set i = Sheets("Employee Inventory")
Set e = Sheets("EEs")
Dim d
Dim j
d = 1
j = 2

Do Until IsEmpty(i.Range("Q" & j))

If i.Range("Q" & j) = "TERM" Then
d = d + 1
e.Rows(d).Value = i.Rows(j).Value

End If
j = j + 1
Loop

Reply to Helper

4

 Anne, on Sep 10, 2009 7:01:42 pm BST

Thanks! That is really helpful to me as well.
Just one more thing: How is it possible to copy data always on the fist empty row on the correspondant sheet (here EES sheet), if this sheet can contain altering number of rows time by time.

Thanks,
Anne

Reply to Anne

2

MattG, on Apr 28, 2009 9:54:57 am BST
  • +5

This code is really helpful!

I'm having problems using it to copy and paste using more than one IF statement.

For example...

Set a = Sheets("Sheet1")
Set b = Sheets("Sheet2")
Set c = Sheets("Sheet3")
Dim x
Dim z

x = 1
z = 2

Do Until IsEmpty(a.Range("B" & z))

If a.Range("B" & z) = "TERM" Then
x = x + 1
b.Rows(x).Value = a.Rows(z).Value

Else

If a.Range("B" & z) = "ACTIVE" Then
x = x + 1
c.Rows(x).Value = a.Rows(z).Value

End If
End If
z = z + 1
Loop
End Sub

The code does work but doesn't remove the blank lines between the copied data - how do I remove these?

Many thanks

Reply to MattG

3

critenlee, on Aug 22, 2009 1:56:15 am BST

Thanks for your sharing. Thanks for sharing this useful information. It's great.



[url=http://sonneriegratuite.org/][color=#FFFFFF][u]gratuit pour mobile sonnerie portable mp3/u/color/url[color=#FFFFFF] - Sonnerie portable MP3 est en effet un pouvoir de l'innovation technologique. Êtes-vous familier avec cette sonnerie portable?/color[url=http://sonneriegratuite.org/][color=#FFF­FFF][u]gratuit pour mobile sonnerie portable mp3/u/color/url

Reply to critenlee