Check if range meets criteria if its not in criteria copy to different column

  • Hi,


    I am trying to create a macro that check whether a range has dates in it and if the values aren't dates then copy those values accross to to a different column but the same row.


    heres my code so far, I am stuck on how to copy accross


  • Re: Check if range meets criteria if its not in criteria copy to different column


    this works for me


  • Re: Check if range meets criteria if its not in criteria copy to different column


    Pangolin


    That worked for me as well.


    Thank you very much

  • Re: Check if range meets criteria if its not in criteria copy to different column


    Hi pangolin


    if possible, I also want it to copy the corresponding range rows to a different worksheet


  • Re: Check if range meets criteria if its not in criteria copy to different column


    just change this line


    Code
    Sheet1.Range("E" & cell.Row) = cell.Value
  • Re: Check if range meets criteria if its not in criteria copy to different column


    change it to this?


    Code
    Sheet1.Range(myCell.Row).Copy Destination:=Sheets("calc")
  • Re: Check if range meets criteria if its not in criteria copy to different column


    Hi


    I changed it to this:


    Code
    myCell.EntireRow.Copy Destination:=Sheets("calc").Range("A" & Rows.Count).End(xlUp).Offset(1)


    sorry this loops copying and pasting in the second row of the the calc sheet

  • Re: Check if range meets criteria if its not in criteria copy to different column


    Rows.count calculate the rows from a activated sheet. You have to use like this -


    Code
    myCell.EntireRow.Copy Destination:=Sheets("calc").Range("A" & Sheets("calc").Rows.Count).End(xlUp).Offset(1)
  • Re: Check if range meets criteria if its not in criteria copy to different column


    what I meant was either one of the two


    Code
    Sheet2.Range("A" & myCell.Row) = myCell.Value


    OR


    Code
    Sheets("Sheet2").Range("A" & myCell.Row) = myCell.Value


    OR

    Code
    myCell.EntireRow.Copy Destination:=Sheet2.Range("A" & myCell.Row)
  • Re: Check if range meets criteria if its not in criteria copy to different column


    Yes that worked, but how do i make it paste without any spaces?

  • Re: Check if range meets criteria if its not in criteria copy to different column


    Pangolin, thanks again. ended up working out the empty cell things myself.


    but very much appreciated

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!