excel vba - How to copy specific cells from each row in another sheet if certain condition is met? -


So my problem is I have a workbook that has two sheets. I have automatically created second program and Sheet1 to Sheet 2, where I only need some information from Sheet 2.

I am now attempting to create a macro which will check each line from 14 with values ​​in more than 15%. If the situation is complete, then I can say the macro in sheet 1 A5 and B5 for C% and E% and then paste it in sheet 2 in the same row as A6B6 and so on. Sub-testing () Dimension Range as a Range Range Varies with Sheets in the form of Long Sheesh in the Last Line ("Sheet 2") lastRow = . Category ("E" & amp; .Rows.Count) End (XLEP) .roet RNG = .Renz ("E14: E" and last time) for each cell in RNG if the cell.Value & gt; 15 'Then this is the place where it becomes stratified, I know that there is something wrong in it. But I could not have thought in any other way that 'only 2 cells are required. Select range (cell.offits (0, -1), cell.office (0, 0)). Select 'Copy' Here you must select some code to copy, but since it has already happened, no solution could actually be found. Sheets ("Sheet1"). Select ActiveSheet.Paste Sheet ("Sheet2"). Select end with end and end end end and end

It seems that I will put it together:

  sub test () in the form of a long dim cell, with a longer number = 0 sheets ("Sheet 2") as a different slow calculation lastRow = .Renz ("e" and.rows.Count). End (XLEEP) .roet RNG = .Renz ("E14: E" and last row) in each cell in RNG if cell.Value & gt; 15 'Then this is the place where it becomes stratified, I know that there is something wrong in it. But I could not have thought in any other way that 'only 2 cells are required. Select range (cell.offets (0, -1), offset (0, 0)) .Copy 'Probably Use: Range (Cell Offset (0, -1), Cell Offset (0, 0) ) .Copy 'Here some code should be selected where the copied data should be kept, but since it has already been messed up, in fact it can not be solved. Sheet ("sheet 1"). Active range ("A5", B5). Offset (counting, 0). Paste Special 'It will do this that it starts in 5, and do not forget to count count = count + 1' 'count sheet ("sheet 2").  

If you can get some error handling like this: if cell.value = "" then or if not then numeric (cell. Value) then and both of them will be sure that you are processing only empty cells with numbers.


Comments