+ Reply to Thread
Results 1 to 6 of 6

Help! I need to populate data based on single cell input

  1. #1
    Registered User
    Join Date
    10-27-2014
    Location
    Fountain, CO
    MS-Off Ver
    07
    Posts
    4

    Help! I need to populate data based on single cell input

    ok so... I have a worksheet that I am trying to get to auto populate... I tried formulas and I am sure I need code for this. I am new to code so please let me know if anyone has an awnser, code, and how to impliment it in the sheet...

    basically... if D17 is equal to or greater than 18 then, B31=B7,G31=G7, B33=B9, E33=E9, G33=G9, I33=I9, B35=B11, E35=E11, H35=H11, B37=B13, G37=G13, B38=B14, E38=E14, H38=H14, B39=D15, F39=B17, I39=B18. If it is less than 18 then leave B31, G31, B33, E33, G33, I33, B35, E35, H35, B37, G37, B38, E38, H38, B39, F39, I39 blank for new data to be populated.

    I was given this code: but I get an error - on the line "If Intersect(Target, Range("D17")) Then"

    - the error states

    Run-time error '91':
    object variable or with variable not set


    Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False

    If Intersect(Target, Range("D17")) Then
    If Range("D17") >= 18 Then
    Range("B31").Formula = "=B7"
    Range("G31").Formula = "=G7"

    'OR IF YOU WANT VALUES INSTEAD

    'Range("B31").Value = Range("B7").Value
    'Range("G31").Value = Range("G7").Value
    End If

    Else
    Range("B31").Clear
    Range("G31").Clear

    End If

    Application.EnableEvents = True

    End Sub


    Can anyone help?

  2. #2
    Forum Contributor
    Join Date
    10-16-2014
    Location
    Center Line, Michigan, United States
    MS-Off Ver
    MS Office 2013
    Posts
    139

    Re: Help! I need to populate data based on single cell input

    Hello markh719, welcome to the forum,

    If you could, please supply a sample worksheet with private data removed. I think you can solve this with a formula, unless you want the cells that would change to not just show a blank, but actually be cleared.

    If you want to stick to code, modify your intersect line to this and give it a try:
    Please Login or Register  to view this content.
    Last edited by Loganeb; 10-27-2014 at 10:31 PM.
    Please click the star (add rep) if I helped!

  3. #3
    Registered User
    Join Date
    10-27-2014
    Location
    Fountain, CO
    MS-Off Ver
    07
    Posts
    4

    Re: Help! I need to populate data based on single cell input

    Sure, this is only the first step of what I need done... I have attached the spreadsheet, basically I need to not replicate the data if I dont need to

    so if the patient is over 18, then the legal guardian info should be the same as the patient, I cant leave it blank, but I dont want to enter the data twicetest book 1.xlsm

    I hope it attached correctly...

    secondly is the policy holder, if it is yes then the patient info should be the same and copy over

  4. #4
    Forum Contributor
    Join Date
    10-16-2014
    Location
    Center Line, Michigan, United States
    MS-Off Ver
    MS Office 2013
    Posts
    139

    Re: Help! I need to populate data based on single cell input

    Will you be copying this data into another sheet? Will this be a template? Or do you want a macro to run when you press a button once you're done? It is easy to put formulas that will fill with the information if the age is 18+, and will appear blank if the age is below 18, but the formulas would still be in the cells. If you were copying the data to another sheet as values, the cells would be blank. If you were to type into the cells, you'd be typing over the formula. Formulas would solve the issue if this is to be a template that you're not going to save over, but if you're going to overwrite the cells each time, a macro will be the way you want to go.

  5. #5
    Registered User
    Join Date
    10-27-2014
    Location
    Fountain, CO
    MS-Off Ver
    07
    Posts
    4

    Re: Help! I need to populate data based on single cell input

    this will be the template, I want the users to only be able to enter data into the highlighted cells, if the patient is 18 or over then the guardian info will be the same. if the patient is the polich holder then again the patient info is the same, ditto on the secondary ins carrier.. and so on, I just cant figure it out.. thanks for your help.. once the patient info is entered then the form will be saved under the patient name, and a new blank template will be opened for the next patient

  6. #6
    Forum Contributor
    Join Date
    10-16-2014
    Location
    Center Line, Michigan, United States
    MS-Off Ver
    MS Office 2013
    Posts
    139

    Re: Help! I need to populate data based on single cell input

    Here, this code should help you.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Populate a range of cells based on a single cell with a variable value
    By RichardMichael in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-27-2014, 08:30 AM
  2. Populate a list based on a single cell
    By poppet in forum Excel General
    Replies: 7
    Last Post: 04-09-2014, 01:39 AM
  3. 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
  4. Formula to populate cell based on data input elsewhere
    By Unca Wook in forum Excel General
    Replies: 1
    Last Post: 11-03-2010, 07:05 PM
  5. Populate a cell based on input from a drop down list
    By TroyDurham in forum Excel General
    Replies: 9
    Last Post: 01-19-2009, 09:47 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