AutoFill in after Autofilter

999HelpPlease

New Member
Joined
Jul 16, 2014
Messages
35
I have a spreadsheet that I want to autofilter column d and column z and then autofill information into column AD. ex if column D is "CA00" and column Z is "TO" then fill in column AD with "House". Then I would like to continue with a different set of criteria and fill in different information. Is there a way to write a VBA to accomplish this?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Maybe:

Code:
Sub HelpPlease999()
Dim i As Long
Dim x As String
Dim y As String
x = InputBox("Please Enter Your First Criteria")
y = InputBox("Please Enter Your Second Criteria")
For i = Range("D" & Rows.count).End(3)(1).row To 2 Step -1
    If Range("D" & i) = x And Range("Z" & i) = y Then Range("AD" & i) = "House"
Next i

End Sub
 
Upvote 0
John Davis, When I copied this code in it didn't do anything. I would also like to write it where it was specific to CA00 and RC and House. Once I figure that out I can duplicate the code to run everything else. This is something that is run every week and we don't want to fill in the input boxes as there are numberous options and that would slow us down. Any suggestions?
 
Upvote 0
Try:

Code:
Sub HelpPlease999()
Dim i As Long
For i = Range("D" & Rows.count).End(3)(1).row To 2 Step -1
    If Range("D" & i) = "CA00" And Range("Z" & i) = "RC" Then Range("AD" & i) = "House"
Next i

End Sub
 
Upvote 0
It worked perfectly. Is there a way to continue the code now stating d=ca01, z=sg and ad=Nate and continue with many variables or should i just write them individually and put one macro to run them one after the other.
 
Upvote 0
John Davis, thank you for your help. I decided to write individual ones and run one macro. It worked perfectly. It is great that you are willing to share your knowledge with people who are just starting out. Again thank you.
 
Upvote 0
It worked perfectly. Is there a way to continue the code now stating d=ca01, z=sg and ad=Nate and continue with many variables or should i just write them individually and put one macro to run them one after the other.

Maybe incorporating a select case?

Code:
Sub HelpPlease999()
Dim i As Long
For i = Range("D" & Rows.count).End(3)(1).row To 2 Step -1
    Select Case Range("D" & i).Value
        Case Is = "CA00"
            If Range("Z" & i) = "RC" Then Range("AD" & i) = "House"
        Case Is = "CA01"
            If Range("Z" & i) = "SG" Then Range("AD" & i) = "Nate"
        ' Case so on and so on
    End Select
            
Next i

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,996
Members
452,373
Latest member
TimReeks

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