Results 1 to 4 of 4

Auto populate column based on drop list, auto populate other columns

Threaded View

  1. #1
    Registered User
    Join Date
    03-14-2010
    Location
    Scotland
    MS-Off Ver
    Excel 2003 + 2007
    Posts
    10

    Auto populate column based on drop list, auto populate other columns

    I am still a newbie trying to fly when I can hardly even crawl yet.

    This code on it's own works fine to populate Master SHEET Columns D,E,F,G based on what is pasted into Master SHEET Column B.

    Ref: CODE A
    Option Explicit
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim RNG As Range
    
        Application.EnableEvents = False
        On Error Resume Next
        Set RNG = Range("B:B").SpecialCells(xlConstants)
        If Not RNG Is Nothing Then
            RNG.Offset(1, 2).FormulaR1C1 = "=""Deny from "" & RC[-2]"
            RNG.Offset(1, 3).FormulaR1C1 = "=""Allow from "" & RC[-3]"
            RNG.Offset(1, 4).FormulaR1C1 = "=""/sbin/iptables -A INPUT -p udp -s "" & RC[-4]& "" -j DROP"""
            RNG.Offset(1, 5).FormulaR1C1 = "=""/sbin/iptables -A INPUT -p tcp -s "" & RC[-5]& "" -j DROP"""
        Else
            ActiveSheet.UsedRange.Offset(1).Clear
        End If
        Application.EnableEvents = True
        
    End Sub
    This code on it's own partially works in that a selection from the drop list will get data just not the correct data, it gets all data.

    Ref: CODE B
    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim LR As Long
        LR = Sheets("Data").Cells.Find("*", Cells(Rows.Count, Columns.Count), SearchOrder:=xlByColumns, _
                               SearchDirection:=xlPrevious).Row
    
        Application.ScreenUpdating = False
        Application.EnableEvents = False
    
        Sheets("Master").UsedRange.Offset(2, 0).ClearContents
    
        With Sheets("Data")
            .AutoFilterMode = False
            .Range("A2:AA" & LR).AutoFilter Field:=1, Criteria1:= _
                                           Sheets("Master").Range("A1").Value
    
            .UsedRange.Offset(1, 0).SpecialCells(xlVisible).Copy
            Sheets("Master").Range("B2").PasteSpecial
            .AutoFilterMode = False
        End With
        
        Application.CutCopyMode = False
        Application.EnableEvents = True
        Application.ScreenUpdating = True
    
    End Sub
    What should it do?

    The drop list should have a blank line when selected this clears the sheet below Row 1 so as to preserve headers.

    When you select from the drop list the macro should find the column of data related to that selection
    and automatically populate Master SHEET Column B (CIDR).

    With Master SHEET Column B (CIDR) populated trigger the population of Columns D,E,F,G

    Example:
    If AF - AFGHANISTAN is selected this should only get Column A from SHEET Data and populate Master SHEET Column B (CIDR).

    The now populated Master SHEET Column B (CIDR) should trigger Ref: CODE A which should now populate Master SHEET Columns D,E,F,G

    Attached workbook is using Ref: CODE B as a filter function in module 1 manually run for now so as to not interfere with macro in Master SHEET
    Attached Files Attached Files
    Last edited by wolfen; 02-27-2012 at 10:43 PM.

Thread Information

Users Browsing this Thread

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

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