Thank you Nishant Jain I will reask the question in a more simple way because the code does nothing to my document and I have no idea why.
So here is what I want to do: I have 2 sheets : Sheet1 (where the data come from) Sheet2 (where I want the data to be copied) In Sheet1, I have 4 columns A: "X or N/A" B : "Code" C : "Date" D: "N. of hours" In Sheet2, I have 3 column A: "Name" B: "Code" C: "Date" D: "N. of hours". I want the macro to do the following: In sheet1, copy the line from B to D (not the other columns) ONLY if there is an "X" in column "A" Paste it in Sheet2 at the last unoccupied line of the table. Paste Sheet1 columns BCD to Sheet2 columns BCD. (The date for column "A" will come from another sheet.) Tahnk you so much for your help! Souriane On 17 juin, 01:05, Nishant Jain <nishantjai...@gmail.com> wrote: > try this > Sub Copy() > Dim i As Integer > Dim j As Integer > > 'find the next available cell to paste the data > j = 2 > Do While ThisWorkbook.Sheets(2).Range("B" & j) <> "" > j = j + 1 > Loop > > 'check whether the next cell is "X" and if yes then paste the value in > next sheet > i = 2 > Do While ThisWorkbook.Sheets(1).Range("A" & i) <> "" > If ThisWorkbook.Sheets(1).Range("Q" & i) = "X" Then > ThisWorkbook.Sheets(2).Range("R" & j) = ThisWorkbook.Sheets > (1).Range("A" & i) > ThisWorkbook.Sheets(2).Range("S" & j) = ThisWorkbook.Sheets > (1).Range("B" & i) > j = j + 1 > End If > i = i + 1 > Loop > End Sub > > On Jun 16, 10:38 pm,Souriane<jsouri...@videotron.ca> wrote: > > > > > Hi! > > > I need help with the an Excel macro. > > > On my worksheet, I have a monthly calendar where we can enter > > someone's working time. > > > Beside it, starting on cell Q4, I have a 4 columns table that takes > > the information from the calendar and make it ready to be transfer to > > another worksheet where we will be able to "play" with the number. > > > I want the macro to take the info in the table and transfer it in my > > second worksheet as follow: > > > 1. Check in column Q if there is an "X" or a "N/A" > > 2. If "N/A", then nothing. (if empty also!) > > 3. if "X" then the following: > > 4. copy info in column R > > 5. paste it in worksheet B, at the end of the existing table (that > > range from column A to D), in column "B" > > 6. copy info in column in column S > > 7. paste *THE VALUE ONLY* in worksheet B in column "C" > > > and the rest, I think I will be able to do it. > > > This macro will teach me how to do other similar one because it covers > > something that I often wish to do but can't yet. > > > Thank you for your help! > > >Souriane- Masquer le texte des messages précédents - > > - Afficher le texte des messages précédents - --~--~---------~--~----~------------~-------~--~----~ ---------------------------------------------------------------------------------- Some important links for excel users: 1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at http://www.excelitems.com 2. Excel tutorials at http://www.excel-macros.blogspot.com 3. Learn VBA Macros at http://www.vbamacros.blogspot.com 4. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com If you find any spam message in the group, please send an email to: Ayush Jain @ jainayus...@gmail.com or Ashish Jain @ 26may.1...@gmail.com <><><><><><><><><><><><><><><><><><><><><><> HELP US GROW !! We reach over 5,000 subscribers worldwide and receive many nice notes about the learning and support from the group. Our goal is to have 10,000 subscribers by the end of 2009. Let friends and co-workers know they can subscribe to group at http://groups.google.com/group/excel-macros/subscribe -~----------~----~----~----~------~----~------~--~---