nabeelahmed
Board Regular
- Joined
- Jun 19, 2020
- Messages
- 76
- Office Version
- 365
- Platform
- Windows
Hi everyone, I am copying data from one sheet to other using PRNo criteria, whenever i enter PRNo. in cell "from" and "To" and how many time i press my Macro Button it is being copy every time to the next row, i don't want same PRno. data to be copied more than one time. It should be copy once and for the next entry when i will use another PRno. then next data should be copy in the next rows and so on..... my coding is below .
Private Sub CommandButton1_Click()
Dim fromPRNo As String: fromPRNo = Sheet2.[E3].Value
Dim ToPRNo As String: ToPRNo = Sheet2.[F3].Value
Application.ScreenUpdating = False
With Sheet1.[A1].CurrentRegion
.AutoFilter 3, ">=" & fromPRNo, xlAnd, "<=" & ToPRNo
.Offset(1).EntireRow.Copy Sheet2.Range("A" & Rows.Count).End(3)(2)
.AutoFilter
End With
Sheet2.Columns.AutoFit
Application.ScreenUpdating = True
End Sub
Private Sub CommandButton1_Click()
Dim fromPRNo As String: fromPRNo = Sheet2.[E3].Value
Dim ToPRNo As String: ToPRNo = Sheet2.[F3].Value
Application.ScreenUpdating = False
With Sheet1.[A1].CurrentRegion
.AutoFilter 3, ">=" & fromPRNo, xlAnd, "<=" & ToPRNo
.Offset(1).EntireRow.Copy Sheet2.Range("A" & Rows.Count).End(3)(2)
.AutoFilter
End With
Sheet2.Columns.AutoFit
Application.ScreenUpdating = True
End Sub