+ Reply to Thread
Results 1 to 6 of 6

Inserting columns ruins fill in form

  1. #1
    Forum Contributor
    Join Date
    11-14-2004
    Location
    Watford, England
    MS-Off Ver
    Microsoft Office 365
    Posts
    131

    Inserting columns ruins fill in form

    Hi All,

    I use the following code for a fill in form to add data.
    Please Login or Register  to view this content.
    This works fine until I insert a new column and unlike most things in excel the form does not realize and compensate for the new column. Is there any way for VBA to account for adding new columns?

    Thanks

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,165

    Re: Inserting columns ruins fill in form

    Hi fastcar,

    You are correct that VBA was blind to adding that new column and now things are screwed up. The fix for this is to used named ranges that are written into your VBA code. Then when you insert a column the named range moves with it....

    Instead of:
    Please Login or Register  to view this content.
    you might try to loop this stuff and do a:
    Please Login or Register  to view this content.
    I'd need to play with your code a bit to see how to code for TextBox1.Text and then TextBox2.Text as my code might not work as written above.

    It would be more help if we had the workbook with the code to try to reduce your code.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Contributor
    Join Date
    11-14-2004
    Location
    Watford, England
    MS-Off Ver
    Microsoft Office 365
    Posts
    131

    Re: Inserting columns ruins fill in form

    Hi,

    Thanks for the reply.

    As requested I have made a temp file to assist.

    Thanks for the great support.
    Attached Files Attached Files

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,165

    Re: Inserting columns ruins fill in form

    Ok fastcar,

    I needed to hunt around and find a VBA name for TextBox1 as an Index. It turned out to be Controls(index)… See the attached and look at the code that I've remed out (green). Let me know if it makes sense. I needed to use the immediate window to see the index number of your controls on your userform.

    Form Control For Next Loop.xlsm

  5. #5
    Forum Contributor
    Join Date
    11-14-2004
    Location
    Watford, England
    MS-Off Ver
    Microsoft Office 365
    Posts
    131

    Re: Inserting columns ruins fill in form

    Hi Marvin,

    I am not that good at coding so am not really sure what you did however.....

    I opened the file and run the form to update details and it worked fine but then I added a column between AI and AJ which moved AJ to AK. Then I tried the update driver details again and it did not realise that what was in col AJ is now AK so when I put some information in the fill in form in "Date of Licence Check" it placed this data in AJ (the new col I inserted) not AK as it is now know.

    I hope I am explained this correctly, just to summerise the fill in form worked fine as it was but it did not allow me to insert extr columns of even move colums around as the fill in form is column fixed if you get my meaning.

    Thanks for the help.

  6. #6
    Forum Contributor
    Join Date
    11-14-2004
    Location
    Watford, England
    MS-Off Ver
    Microsoft Office 365
    Posts
    131

    Re: Inserting columns ruins fill in form

    Is there any further advice that can be given on this?

    Thanks

+ 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. Replies: 9
    Last Post: 09-16-2015, 08:45 PM
  2. Replies: 6
    Last Post: 05-01-2014, 06:04 PM
  3. Auto Fill Web Form using Excel User Form
    By vandanavai in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-09-2008, 02:26 AM
  4. Problem with adding and deleting columns, ruins code
    By frshca in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-22-2008, 12:08 PM
  5. Sorting ruins my formula!
    By steven314 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-15-2007, 04:02 PM
  6. [SOLVED] Fill in form to type Item descrictions and costs and fill in funct
    By cradino in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-16-2006, 03:45 PM
  7. [SOLVED] Inserting Form form Visual Basic...
    By thomas in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-25-2005, 05: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