Filter column and print specific value to the next column in macro

manoj_arsul

Board Regular
Joined
Jun 27, 2018
Messages
61
Hi ,
Please help me to create program in Macro for below condition

1) filter column C for 3 names "Available " , "Not available " & "Expired".
2) Print Text "Its Available" in G Column next to "Available"
3) Print text "Its Not Available" in G Column next to "Not Available"
4) Print text "The Product is Expired" in G Column next to "Expired"
-
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
In G1 =IF(C1="Available","It's Available",IF(C1="Not Available","It's Not Available","The Product is Expired")) and copy down.
 
Upvote 0
One macro suggestion:
Code:
Sub M1()

    Dim arr As Variant
    Dim x   As Long
    
    arr = Cells(1, 3).Resize(Cells(Rows.Count, 3).End(xlUp).Row).Value
    
    For x = LBound(arr, 1) To UBound(arr, 1)
        If InStr(arr(x, 1), "Available") Then
            arr(x, 1) = "Its " & arr(x, 1)
        ElseIf InStr(arr(x, 1), "Expired") Then
            arr(x, 1) = "The Product is " & arr(x, 1)
        Else
            arr(x, 1) = vbNullString
        End If
    Next x
    
    Cells(1, 7).Resize(UBound(arr, 1), 1).Value = arr
    Erase arr
    
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,213
Members
452,618
Latest member
Tam84

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top