简体   繁体   中英

If column X contains value, add column Y value to worksheet range

I'm sure this has been answered elsewhere, however I require specific help with the development of the required VBA code.

The scenario: A membership database (worksheet "Members") contains members details including whether they are "Active" or not.

I am trying to make the program look down Column C; if cell contains "ACTIVE" then copy corresponding Column A value to a 2nd worksheet template range, "active members".

Any suggestions will be appreciated.

Kind regards.

This will copy all active users to the second worksheet called Active Members

Sub copyActive()
Dim counter, RowNo As Long

counter = 1
RowNo = 1

    Do Until Sheets("Members").Cells(counter, 1) = ""
    If UCase(Sheets("Members").Cells(counter, 3)) = "ACTIVE" Then
    Sheets("Active Members").Cells(RowNo, 1) = Sheets("Members").Cells(counter, 1)
    RowNo = RowNo + 1
    counter = counter + 1
    End If
    counter = counter + 1
    Loop

End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM