Results 1 to 3 of 3

vba code to pull certain columns based on criteria (account name) selected from a dropdown

Threaded View

krunk vba code to pull certain... 05-19-2022, 09:25 PM
nankw83 Re: vba code to pull certain... 05-20-2022, 03:46 AM
AliGW Re: vba code to pull certain... 05-20-2022, 04:05 AM
  1. #1
    Registered User
    Join Date
    02-20-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2010
    Posts
    74

    vba code to pull certain columns based on criteria (account name) selected from a dropdown

    Hi,

    I was hoping someone could help me with my code. I don't normally write code so I've been doing a lot of research to figure out how to achieve this request.

    I wrote a formula that accomplished it but because of the amount of data, it was really slow and took a long time to populate. I believe a VBA code could lessen the processing time.

    see code below:

    Private Sub CommandButton1_Click()

    '1 declare variables
    '2 clear old search results
    '3 find records that match cell c1 from account dashboard sheet

    If Target.Cells.Count > 1 Then Exit Sub
    Application.EnableEvents = False
    If Not Intersect(Target, Range("c:c")) Is Nothing Then
    Dim sh1 As Worksheet, sh2 As Worksheet, rw As Long
    Set sh1 = Sheets("Account_Dashboard")
    Set sh2 = Sheets("Survey Data Lookup")

    Name = Sheets("account_dashboard").Range("c1").Value
    If Target.Value = Name Then
    rw = sh2.Cells.Find("*", , xlValues, xlPart, xlByRows, xlPrevious).Row + 1
    With sh2

    Set fn = sh2.Range("A:A").Find(Target.Offset(, -74).Value, , xlValues, xlWhole)
    If Not fn Is Nothing Then
    .Cells(rw, 2) = sh1.Range("l" & Target.Row).Value 'account email
    .Cells(rw, 3) = sh1.Range("r" & Target.Row).Value 'role in company
    .Cells(rw, 4) = sh1.Range("cs" & Target.Row).Value 'survey type
    .Cells(rw, 5) = sh1.Range("CB" & Target.Row).Value 'division
    .Cells(rw, 6) = sh1.Range("cc" & Target.Row).Value 'sub-division
    .Cells(rw, 7) = sh1.Range("cl" & Target.Row).Value 'wrk contact name
    .Cells(rw, 8) = sh1.Range("A" & Target.Row).Value 'survey date
    End With
    End If
    End If

    Application.EnableEvents = True
    End Sub


    Thank you in advance for the help.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Return selected dropdown values based on previous dropdown
    By Bundok@mac.com in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-27-2018, 08:32 AM
  2. Replies: 2
    Last Post: 03-07-2018, 07:31 PM
  3. [SOLVED] Help returning values from columns based on user selected criteria
    By petelozzi in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-04-2016, 06:28 PM
  4. Dropdown selections based on adjacent dropdown selected
    By mtvufg8r in forum Excel General
    Replies: 2
    Last Post: 11-07-2014, 12:25 PM
  5. [SOLVED] How to pull data based on Filtered results - To create Statement of Account
    By ec4excel in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 06-28-2013, 11:36 AM
  6. [SOLVED] Function to return 2 columns based on 2 user selected criteria
    By lax2734 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-07-2013, 04:36 PM
  7. VBA code for coping selected data to another sheet based on a criteria
    By BJ5352 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-14-2010, 02:16 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1