+ Reply to Thread
Results 1 to 5 of 5

[VBA] Setting a range with textboxes

  1. #1
    Registered User
    Join Date
    07-13-2017
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    12

    Lightbulb [VBA] Setting a range with textboxes

    Hi there everyone,

    [I apologise for the length of this post, It's my first time posting and I wanted to be descriptive so it would be easier to understand the problem]

    For the past few months when I've had spare time I have been working on a userform project, and have always appreciated the help of other users on forums such as these. It has finally come to a time where I must post for help since I am stuck and unsure how to proceed.

    Simply put, I have some code that inserts a table into your spreadsheet.

    Usually, it always inserts a table from a set cell (A15) and the no. rows down it goes depends on the value of a textbox. Here it is below:

    Please Login or Register  to view this content.
    It is very important that the table created equals the number in the textbox (as this is the number of samples)

    So for example, if the textbox has a value of 5 (5 samples need to be in the table), so the range will be from A5:15, the "+15" is there to give the correct table size, so the final range will be A15:A20 (thus the sample size of 5 is made as per the textbox)


    I also want to add a feature whereby a user can choose wherever they would like to place the table (ie: free movement), however I keep getting a weird issue. This is what code I'm using:

    Please Login or Register  to view this content.
    I should note that:
    Textbox 16 is for the letter reference (ie: G)
    Textbox 17 is the number part (ie: 5)
    so both these form a full cell (ie: G5)

    Lets assume TextBox3 is 4 - so 4 for the sample size

    The above code I thought would work like this:
    Range = G + 5 (G5) : G + 3 (G3) + 5
    Therefore making the final range G5:G8 (which is how I need it to be, as the user specifies to insert the table from G5, then the 3 samples take it to G8

    However, when I execute this code, it doesn't add up as a number: instead of doing G3 + 5 = G8 as I thought it would, it does G35
    So it makes a table G5:G35 instead of G5:G8

    Can anyone assist me with fixing this so it computes correctly as I would like it to?

    I appreciate any replies and help, and I would like to apologise for the length of this post (It's my first post so getting use to it!)

    All the best,

    Nathan

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: [VBA] Setting a range with textboxes

    Try it like this...

    Please Login or Register  to view this content.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Registered User
    Join Date
    07-13-2017
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    12

    Re: [VBA] Setting a range with textboxes

    Quote Originally Posted by sktneer View Post
    Try it like this...

    Please Login or Register  to view this content.
    Thank you so much!

    It works perfectly, now I can continue on with my project

    Appreciate the assistance my friend

  4. #4
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: [VBA] Setting a range with textboxes

    You're welcome.

    If that takes care of your original question, please mark your thread as Solved by selecting Thread Tools (just above your first post) --> Mark thread as solved.

    You may also say thanks to those who have put their time and efforts to help you in this forum by clicking the Add Reputation link under their posts, another way to say thanks.

  5. #5
    Registered User
    Join Date
    07-13-2017
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    12

    Re: [VBA] Setting a range with textboxes

    Quote Originally Posted by sktneer View Post
    You're welcome.

    If that takes care of your original question, please mark your thread as Solved by selecting Thread Tools (just above your first post) --> Mark thread as solved.

    You may also say thanks to those who have put their time and efforts to help you in this forum by clicking the Add Reputation link under their posts, another way to say thanks.
    Done and done

+ 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. [SOLVED] Select all text in textboxes when i click textboxes in simple way
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-26-2017, 03:27 AM
  2. Creating a dynamic extraction range from values in 8 textboxes
    By jheidens in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 10-03-2015, 03:05 PM
  3. Replies: 0
    Last Post: 02-04-2015, 03:46 PM
  4. [SOLVED] Color Textboxes in Userform If Tetxbox name is in Range
    By Jonathan78 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-03-2014, 03:04 AM
  5. Setting Fill color for Textboxes
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-14-2011, 01:33 PM
  6. Setting up Multicolumn Combobox to update different Textboxes
    By paxile2k in forum Word Programming / VBA / Macros
    Replies: 0
    Last Post: 11-18-2010, 09:34 PM
  7. Setting textbox1's name as a string so i can loop through 10 textboxes
    By justchris in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-24-2005, 05:40 PM

Tags for this Thread

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