write textbox value to range1 cells based on value of range2 cells

  • Okay, I have 2 questions that fall under this same topic, I think the workaround will probably be the same for both, but I'm not sure
    Question1:
    I have the following code

    Code
    For Each cell In Range("D8:D11")
            If cell.Value <= Range("M2").Value Then
                Cells(cell.Row, 13).Value = Me.TextBox1.Value
            End If
    Next



    What the code is doing:
    If D8 <= M2 then textbox1.value is being written to M8, M9, M10, M11
    If D9 <= M2 then textbox1.value is being written to M8, M9, M10, M11
    and so on....


    What I'm trying to do:
    If D8 <= M2 then write textbox1.value to M8
    If D9 <= M2 then write textbox1.value to M9
    and so on...


    How do I get my range(D8:D11) to write to their respective cells in range(M8:M11) without update the rest of the cells in M8:M11


    Question 2:
    In the next code


    The code works to where if D8 > M2, then a cell in N2:EK2 is populated with the textbox value if D8 = a column in N2:EK2
    Unlike above, the textbox value for each cell in range D8:D11 is written seperately to it's appropriate row BUT to following occurs:
    If row 8 user input: textbox1.value = "name1", then the appropriate cell in row 8 will contain "name1"
    But if row 9 user input: text1.value = "name2", the appropriate cell in row 9 will contain "name2" AND the "name1" in row 8 will change to "name2"
    How do recognize these as separate entities without having to create a new userform/textbox for each case?


    Thank you excel experts for your time!

  • Re: write textbox value to range1 cells based on value of range2 cells


    forum.ozgrid.com/index.php?attachment/52001/


    See attached.
    Instructions:
    For questions 1:
    1. In cell D8 type: 3/1/2013
    2. In cell E8, a) type any text in userform that pops up
    b) enter a date post today's date (you don't need to do this step, but if you enter a date less than today's date, the text will be erased - this is ok)


    Then you will see my problem to question 1


    For question 2:
    1. Press delete on cells D8 & E8 (if there are any entries in these cells)
    2. In cell D8 type: 3/18/2013
    3. In cell E8: a) type any text in userform that pops up
    b) enter any date post 3/18/2013
    4. In cell D9 type: 3/18/2013
    5. In cell E9: a) type any text in userform (text different than wht you entered in E8)
    you will see that the text entered for E9 will overwrite what was previously written for E8

  • Re: write textbox value to range1 cells based on value of range2 cells


    hmmm dont realy follow but M2 in a day and D8 is a day/month/year
    so there is a format difference maybe M2 should be C3?


    if you dont want to override dates

    Code
    If cell.Value = Range("D8").Value and Cells(8, cell.Column).Value="" Then 
            Cells(8, cell.Column).Value = Me.TextBox1.Value
  • Re: write textbox value to range1 cells based on value of range2 cells


    Would you want each Item to have it's own userform Osborsm? So you would only ever be having 4 Items and userforms?

  • Re: write textbox value to range1 cells based on value of range2 cells


    M2 does = C3, you can see the formula when you click the cell (see red markings in picture). The numbering below is just formatted for visual effect. Row 2 is what contains all the date calculations. So M2 is in month/day/year format which matches D8
    [ATTACH=CONFIG]52057[/ATTACH] (click on picture to enlarge)


    I'm trying not to have a userform for each cell. See green markings in the picture - these cells will all be needing the same formula I'm trying to create for D8. Whatever works for D8 will be copied into all of these cells. And this excel sheet is only an example of my actual table - in my actual table, I have many more rows, which means I would need to manually create anywhere between 100-200 userforms.
    However, my columns are unchanged, so I would like to find a way where I can apply the userform to the column and make this code work for each cell in the column without having input into one cell cause input into all of their subsequent cells.


    If you follow the instructions exactly as I have listed above in the attachment I added previously, you'll see the issue


    Pike - Thanks for trying, but the code doesn't work, if I use your command, the active cell remains blank while the other cells are populated with my textbox output

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!