none
Help with Excel Macro RRS feed

  • Question

  • I need help with a Macro please. I am new to this and have done well so far at creating userforms but I am really stuck on the last task I need to finish. I need to copy and paste a range of cells [G5:G33]from  sheet1 into sheet2 based on words typed in to Cells A4:C4. For instance if the word is A4 is Red, the word in Cell B4 is Blue and the word in Cell C4 is green then the range of G5:G33 on sheet1 will be copied into range H5:H33 of sheet2. Any help would be greatly appreciated! Thanks!
    Tuesday, November 19, 2013 7:59 PM

Answers

  • Re:  copy cells based on condition

    '---
    With Worksheets("Sheet1")
       If .Range("A4").Value & .Range("B4").Value & .Range("C4").Value = "RedGreenBlue" Then
          .Range("G5:G33").Copy Destination:=Worksheets("Sheet2").Range("H5:H33")
      End if
    End With
    '---
    Note the leading dots that connect the ranges to the sheet1 worksheet.
    '---
    Jim Cone
    Portland, Oregon USA
    free & commercial excel programs
    https://goo.gl/IUQUN2 (Dropbox)
    • Marked as answer by Plumpkin07 Tuesday, November 19, 2013 11:27 PM
    • Edited by James Cone Friday, October 14, 2016 12:56 PM
    Tuesday, November 19, 2013 10:40 PM

All replies

  • Re:  copy cells based on condition

    '---
    With Worksheets("Sheet1")
       If .Range("A4").Value & .Range("B4").Value & .Range("C4").Value = "RedGreenBlue" Then
          .Range("G5:G33").Copy Destination:=Worksheets("Sheet2").Range("H5:H33")
      End if
    End With
    '---
    Note the leading dots that connect the ranges to the sheet1 worksheet.
    '---
    Jim Cone
    Portland, Oregon USA
    free & commercial excel programs
    https://goo.gl/IUQUN2 (Dropbox)
    • Marked as answer by Plumpkin07 Tuesday, November 19, 2013 11:27 PM
    • Edited by James Cone Friday, October 14, 2016 12:56 PM
    Tuesday, November 19, 2013 10:40 PM
  • Worked great!!!! Thank you very much!!!
    Tuesday, November 19, 2013 11:27 PM