How to enter a row when an "if condition" is met

Closed
El Magnifico - Aug 12, 2015 at 06:07 AM
vcoolio Posts 1404 Registration date Thursday July 24, 2014 Status Moderator Last seen September 15, 2023 - Aug 12, 2015 at 08:00 AM
Hello,

Would like to know how to add a row in a different sheet when an "if condition" is met.

To illustrate, I have the following columsn in sheet one:

Month Rerence No. Type Client No. Client Name Authority

I would like to condition that should the "authority column" be a certain value, then all the details in that particular "row" be inserted in a different sheet.

Thanks in advance for the help.

Sincerely
Related:

1 response

vcoolio Posts 1404 Registration date Thursday July 24, 2014 Status Moderator Last seen September 15, 2023 259
Aug 12, 2015 at 08:00 AM
Hello El Magnifico,

Something like this should get you started at least:-

Sub CopyIt()

Application.ScreenUpdating = False

With ActiveSheet
.AutoFilterMode = False
With Range("F1", Range("F" & Rows.Count).End(xlUp))
.AutoFilter 1, "Yes"
On Error Resume Next
.Offset(1).EntireRow.Copy
Sheet2.Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValues

End With
.AutoFilterMode = False
End With

Sheet2.Columns.AutoFit
Application.CutCopyMode = False
Application.ScreenUpdating = True
Sheet2.Select

End Sub


You can have a look at my test work book at the following link:-

https://www.dropbox.com/s/ggro8uwtxtey6ym/El%20Magnifico.xlsm?dl=0

The code filters Column F for the criteria "Yes" and transfers the relevant row of data to sheet 2. Click on the "Transfer" button to see it work.

I hope that this helps.

Cheerio,
vcoolio.
0