+ Reply to Thread
Results 1 to 21 of 21

Offset Positions When Unloading Userform

  1. #1
    Registered User
    Join Date
    06-24-2011
    Location
    North East England
    MS-Off Ver
    Office 365
    Posts
    41

    Offset Positions When Unloading Userform

    Hi guys, apologies for the length of this description but I felt it necessary to get all (or most) of the info over...

    As per my other thread today, I am putting together a labour workload sheet that is laid out in a grid of dates along the top and personnell names down the left. I have a VBA code set up within the grid (shown below) so that on double clicking any cell within this grid, three msgboxes in total appear (one after another following data entry). The first msgbox is the 'site reference', which can be multiple entries up to a total of approx 12, all seperated by commas. The second msgbox is for the company job number, which again can be multiple entries and the third box is the hours spent on site, again multpile entries can be made.

    I can't attach sheet due to filesize even when compressed, however my sheet is laid out so that out of every 3 rows within the grid, the two lowest rows are set to row height zero (effectively hiding them from view) and the code takes the data from the last 2 mgsboxes and inserts it into these hidden rows/cells directly below the active cell (data from first msgbox is inserted into current active cell). This hidden data is then viewed via a completely seperate piece of code that references these hidden cells in addition to the active cell in another section of the sheet. Please see code below which works fine when initially entering data:


    Please Login or Register  to view this content.

    My issue with this code is if the data entered needs to be edited at a later date, you must double click the cell again and re-enter everything! Is it possible to create some sort of message box so that when double clicking the cell the msgboxes/forms that pop up still contain the previously entered data that can simply be edited rather than having to re-enter everthing and potentially missing something off?

    Any pointers would be greatly appreciated! Thanks in advance! Any more info needed please just ask...
    Last edited by liam_bettinson; 09-01-2011 at 06:20 AM. Reason: Changing demands of spreadsheet

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Msgbox Editing Info Problem

    Please mark your previous thread as 'solved'

    And dive into the world of VBA 'userforms'.
    Last edited by snb; 08-30-2011 at 06:47 AM.



  3. #3
    Registered User
    Join Date
    06-24-2011
    Location
    North East England
    MS-Off Ver
    Office 365
    Posts
    41

    Re: Msgbox Editing Info Problem

    Quote Originally Posted by snb View Post
    Please mark your previous thread as 'solved'

    And dive into the world of VBA 'userforms'.

    Apologies for being a complete 'noob' to the forum but how do I mark it as solved? I'll check out userforms yeah, any advice on them before I delve??

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Msgbox Editing Info Problem

    You can click in my signature for a 'manual' to mark your threads as 'solved'.

    No one will blame you for reading the forum rules , please do.

  5. #5
    Registered User
    Join Date
    06-24-2011
    Location
    North East England
    MS-Off Ver
    Office 365
    Posts
    41

    Re: Msgbox Editing Info Problem

    Quote Originally Posted by snb View Post
    You can click in my signature for a 'manual' to mark your threads as 'solved'.

    No one will blame you for reading the forum rules , please do.
    Done! Thanks hehe

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Msgbox Editing Info Problem

    You overlooked in the forum rules: please do not quote.....

  7. #7
    Registered User
    Join Date
    06-24-2011
    Location
    North East England
    MS-Off Ver
    Office 365
    Posts
    41

    Re: Msgbox Editing Info Problem

    My apologies, I should have read and will do now

    Regarding the topic of the thread, I've looked into userforms and have created one that pops up upon double clicking a cell on the spreadsheet and contains 3 text entry boxes and a 'done' command button (grid area not actually specified, would like to limit this to D8:BNW900 - any ideas how to edit the below code?)

    Please Login or Register  to view this content.

    The issue I have now is how do I transfer the entered info into a specific area of my grid rather than a generic 'database'? I wish for the first text box data to go into the current active cell, 2nd txt box data into the cell directly below active cell (offset 1, 0) and 3rd box data into 2 cells directly below active cell (offset 2, 0). Any ideas on the code I need?

    Also can anybody advise that following entry of data into the userform, if I double click that cell again to edit the info, will this information still be in the userform for editing? If not how do I achieve this?

    Any more info required please ask...

  8. #8
    Registered User
    Join Date
    06-24-2011
    Location
    North East England
    MS-Off Ver
    Office 365
    Posts
    41

    Re: Insert Userform Txtbox Data Into Active Cell & Offset Positions

    Can anyone help?

  9. #9
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Insert Userform Txtbox Data Into Active Cell & Offset Positions

    To limit the range, something like:

    Please Login or Register  to view this content.
    To put the text into the cells, something like:

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    06-24-2011
    Location
    North East England
    MS-Off Ver
    Office 365
    Posts
    41

    Re: Insert Userform Txtbox Data Into Active Cell & Offset Positions

    Would those 2 pieces of code be mixed together or in seperate subs? Any chance of a full description? Thanks for the help!!

  11. #11
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Insert Userform Txtbox Data Into Active Cell & Offset Positions

    liam_bettinson,

    See attached example workbook based on criteria you've described. Doubleclicking in sheet1, range D8:BNW900 will open the userform. If there is already data in the cell clicked (and/or the two cells to its right), the data will be pulled into the userform. Clicking Done will output the textbox values into the cell that was doubleclicked and the two cells to its right. Let me know if that is what you were looking for

    Hope that helps,
    ~tigeravatar
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    06-24-2011
    Location
    North East England
    MS-Off Ver
    Office 365
    Posts
    41

    Re: Insert Userform Txtbox Data Into Active Cell & Offset Positions

    Tigeravatar, that works great! THanks so much! However I want it to paste the values entered in each text box vertically rather than horizontally, ie all in the same column directly underneath each other on 3 different rows, can this accommodate that?

    Also it has now stopped my other piece of code working that allowed you to view the held data by doing a SINGLE click. Code as follows, please advise if this needs to be changed as it worked ok before entering the code on your spreadsheet:

    Please Login or Register  to view this content.

  13. #13
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Insert Userform Txtbox Data Into Active Cell & Offset Positions

    liam_bettinson,

    Updated example workbook to pull information vertically. Also added the Worksheet_SelectionChange event. I experienced no issues with it. It doesn't auto-update when the userform closes because there's not a selection going on. just click into a cell and it will update. If preferred, the C2, C4, C6 cells can be updated with the userform's submit button as well to keep things seamless.

    Hope that helps,
    ~tigeravatar

    EDIT: Updated attachment to correct one
    Last edited by tigeravatar; 08-30-2011 at 11:37 AM. Reason: Updated attachment

  14. #14
    Registered User
    Join Date
    06-24-2011
    Location
    North East England
    MS-Off Ver
    Office 365
    Posts
    41

    Re: Insert Userform Txtbox Data Into Active Cell & Offset Positions

    Sorry buddy but this is still pasting in the data within one row rather than on 3 rows in a single column?

    Also I've copied the code into my own workbook/VBA and it doesnt seem to work The Userform appears and I can enter the data into the text boxes but when I click the 'Done' command button it does not close and hence does not update my spreadsheet. I've changed all the userform, textbox and button names to match yours exactly, the only properties that are different are the physical text box sizes and fonts but wouldnt imagine that would make a difference would it?! Anything else I'm missing that will prevent it from working?

  15. #15
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Insert Userform Txtbox Data Into Active Cell & Offset Positions

    Edited recent post to have correct attachment, sorry about that

  16. #16
    Registered User
    Join Date
    06-24-2011
    Location
    North East England
    MS-Off Ver
    Office 365
    Posts
    41

    Re: Insert Userform Txtbox Data Into Active Cell & Offset Positions

    No problem my good man. Right...think we're getting near, the example you sent works great but for some reason on my own form it's not working. It all works as it should up until I click 'done' and nothing happens! I'll triple check the names and properties but I'm pretty sure they all match up to what your's a named, anything else I could be missing?

  17. #17
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Insert Userform Txtbox Data Into Active Cell & Offset Positions

    liam_bettinson,

    As long as the control names get updated in your code it should be fine (example: instead of "Me.txt_Data1.Text" it should be "Me.ActualNameOfYourTextControl.Text"). If its still giving you an issue, just post your btn_Done_Click() equivalent code and I'll take a look at it.

  18. #18
    Registered User
    Join Date
    06-24-2011
    Location
    North East England
    MS-Off Ver
    Office 365
    Posts
    41

    Re: Insert Userform Txtbox Data Into Active Cell & Offset Positions

    Cancel my last post, I neglected to copy and paste the code from within the buttons/form! Thanks so much for your help Tigeravatar, greatly appreciated!! Form works a treat now

  19. #19
    Registered User
    Join Date
    06-24-2011
    Location
    North East England
    MS-Off Ver
    Office 365
    Posts
    41

    Re: Insert Userform Txtbox Data Into Active Cell & Offset Positions

    Hi again, apologies to dredge this up, but my boss now wants a couple of changes to the sheet, details as follows:

    Instead of the userform being unloaded in the active cell and the two cells directly below the active cell, this now needs to unload in the cell directly below active cell and the two cells under that (basically everything is shifted down 1 cell from the active cell). I've tried to change the following code which is within the userform to change the offset references at the bottom to suit but the position of unloading does not change. I assume something around the 'Unload me' part needs altering? Any ideas?

    Please Login or Register  to view this content.
    Last edited by liam_bettinson; 09-01-2011 at 06:22 AM.

  20. #20
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Offset Positions When Unloading Userform

    Please Login or Register  to view this content.

  21. #21
    Registered User
    Join Date
    06-24-2011
    Location
    North East England
    MS-Off Ver
    Office 365
    Posts
    41

    Re: Offset Positions When Unloading Userform

    You sir are a true gent! Many thanks once again!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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