jeudi 26 octobre 2017

VBA Code For copying and Pasting with If statement

I need to copy range A1:G200 from one workbook to current workbook (both workbooks active) but I need the code to only copy the rows that meet a certain criteria in column G. Column G only has values ranging from .000 to .999. I need the macro to copy range A1:G200 but only if they are between range .250 and .500 in column G.

I have already created the macro for copying and pasting, which works great but the problem is that I am not too familiar with If statements. Can anyone help me out? Here is what I have so far:

Sub test()

Dim masterWb As Workbook
Dim mySht As Worksheet
Set mySht = ThisWorkbook.ActiveSheet
Set masterWb = Workbooks("JME") 
With masterWb.Worksheets.Add
    .Range("A1:G200").Value = mySht.Range("A1:G200").Value
End With

End Sub

Aucun commentaire:

Enregistrer un commentaire