VBA to pull data based on a cell value

Alphaboss7

New Member
Joined
Jul 31, 2017
Messages
28
Hi Guys,

I know this may be simple, but for the life of me I cannot get this to work. I'm trying to just simply use VBA to lookup values based on a specific cell value.

This specific cell has a drop down list, so depending on the value, the data being pulled will come from different sheets that have identical layouts. I just wanted to use the following code as a pattern to see if I could get it to work based on one value from the dropdown list.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    
        If Range("Team_DrpDn") = "SysAdmin" Then
            For i = 27 To 30
            Range("G" & i).Value = Application.WorksheetFunction.VLookup(Range("E" & i).Value, Sheets("SysAd Historical").Range("E10:G13").Select, 3, False)
            Next i
        End If


End Sub

So I would just replicate the code and use "Network" instead of "SysAdmin" when the specific cell range "Team_DrpDn" changes to that value.

Let me know if that's not enough clarification.

Thanks,
AB7
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
How about
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Sht As String
    Dim i As Long
    
    If Target.CountLarge > 1 Then Exit Sub
    If Target.Address = Range("Team_DrpDn").Address Then
        Select Case Target.Value
            Case "SysAdmin"
                Sht = "SysAd Historical"
            Case "Network"
                Sht = "Network Sheet"
        End Select
        
        For i = 27 To 30
            Range("G" & i).Value = Application.VLookup(Range("E" & i).Value, Sheets(Sht).Range("E10:G13"), 3, False)
        Next i
    End If
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

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