Results 1 to 4 of 4

Using VBA to auto populate cells based on user input (without using formulas if possible)

Threaded View

guyinahatgames Using VBA to auto populate... 11-20-2014, 08:13 AM
humdingaling Re: Using VBA to auto... 11-20-2014, 07:54 PM
guyinahatgames Re: Using VBA to auto... 11-21-2014, 08:44 AM
humdingaling Re: Using VBA to auto... 11-23-2014, 07:48 PM
  1. #1
    Registered User
    Join Date
    11-06-2014
    Location
    UK
    MS-Off Ver
    Office 2003
    Posts
    10

    Using VBA to auto populate cells based on user input (without using formulas if possible)

    Hello

    Windows Server 2005
    Excel 2003

    This is based on the same spreadsheet I used in another thread post. I'm trying to create a spreadsheet where somebody who's computer illitarate can type a product code in column B and it'll auto populate column F and G all done in VBA without using forumlas within the spreadsheet itself.

    Reason being is that I'm under a strict file size limit and have to keep it as small as possible so having a forumla in one cell and dragging it down isn't the best option sorry.

    I tried to create a VBA code which would auto populate the cells by placing the forumla into the cells when needed meaning I don't have to have 4000 rows of formulas sitting there waiting to be used (if that makes sense) but I couldn't get it to work it just returns a value of 0 Also it only works on the one cell not he cells adjasent to each other (sorry I'm explaining that poorly)

    Also this process has to be done automatically without anybody resorting to macro buttons. Of course if anybody can come up with a method of doing this without inputting any forumals at all that'll be grand :D

    Any help would be very apprechiated thank you

    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim rngChange As Range, isect As Range
        Dim r As Integer
     
        If Target.Columns.Count = 256 Then Exit Sub
        
        Application.EnableEvents = False
        
        LastRow = Range("B" & Rows.Count).End(xlUp).Row
        Set rngChange = Range("B4:B" & LastRow)
        Set isect = Intersect(Target, rngChange)
        
        If Not isect Is Nothing Then
            For RowNo = Target.Row To Target.Row + Target.Rows.Count - 1
                Set Target = Cells(isect.Row + r, isect.Column)
                If Target = "" Then
                    Cells(Target.Row, 6) = ""
                    Cells(Target.Row, 7) = ""
                Else
                    Cells(Target.Row, 6) = "=INDEX(Codes!$B$2:$B$1499,MATCH(Register!$F$4,Codes!$A$2:$A$1499,0))"
                    Cells(Target.Row, 7) = "=INDEX(Codes!$C$2:$C$1499,MATCH(Register!$G$4,Codes!$A$2:$A$1499,0))"
                End If
                r = r + 1
            Next
        End If
        
        Application.EnableEvents = True
        
    End Sub
    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. auto-populate based on input
    By JessicaSam in forum Excel General
    Replies: 1
    Last Post: 06-08-2012, 01:47 PM
  2. Code/Macro to populate table based on user input.
    By galvinpaddy in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-08-2011, 07:50 AM
  3. Auto populate based on user input
    By lotusblossom in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 01-20-2011, 02:58 AM
  4. Populate rows in the sheet based on user input in the cell
    By omdkhaleel in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-04-2010, 10:48 AM
  5. Automatically populate a list based on defined categories -- user input varies
    By NearClueless in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-12-2009, 06:05 PM

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