Put data from generated textboxes to specific cells

  • Hello guys,


    I need a little help with my code.
    The final version of the code will be for renaming of column's headers through Userform.
    I have a code to automatically generate TextBoxes of every used column (only the first row for each column) and insert the values to them.


    Then I generated another (blank) TextBoxes, where I want to insert text and the text should rewrite original column's headers.


    I don't know how to address to this generated TextBoxes.


    Any help would be appreciated.


    Here is my code:


    [ATTACH=CONFIG]74025[/ATTACH]

  • Re: Put data from generated textboxes to specific cells


    Hello,


    use index number to name dynamically made textboxes and then refer to them in the loop like in the following:



    s.

  • Re: Put data from generated textboxes to specific cells


    Quote from sysss;800852

    Hello,


    s.


    Just found a mistake in the code... Forgot to replace variable i by variable Ndx... Corrected below:



    Regards,
    s.

  • Re: Put data from generated textboxes to specific cells


    When you make the text box, put the address of the cell it refers to in the .Tag property.


    Code
    With tBox 
                .Width = 60 
                .Height = 20 
                .Left = 10 
                .Top = (Ndx - 0.8) * (30 + dDistHoriz) + 30 
                .Text = Range("A1").Offset(0, Ndx - 1).Value 
                .Tag = Range("A1").Offset(0, Ndx - 1).Address(,,,True)
            End With


    Then when you write to the cell


    Code
    With someTextBox
        Range(.Tag).Value = .Text
    End With
  • I would like to thank you. I didn't know about the reaction on this topic, because I was three weeks away from everything and then I didn't see the notification. I figured it out on myself and it is almost the same code, like you suggested.


    Thank you very much, for your help and sorry for this very late respond.

Participate now!

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