+ Reply to Thread
Results 1 to 8 of 8

My first try with loops...but it is not working... explanation required!

  1. #1
    Forum Contributor
    Join Date
    07-15-2016
    Location
    Maputo, Mozambique
    MS-Off Ver
    2007
    Posts
    108

    My first try with loops...but it is not working... explanation required!


    Hi everybody. I am trying to create a loop to get some values from a sheet and put it in a textbox in another sheet.
    I surely misunderstood something very basic about loops.... fist try and the loop is not working and give me error like type mismatch.

    Have a look at the example please... and tell me what is so very wrong with it!

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: My first try with loops...but it is not working... explanation required!

    Hi,

    What's the ultimate end game here? Can you explain in a narrative since there may be better ways of achieving what you want. Loops should always be a last resort since with large ranges they can seriously affect the time taken to achieve the task.

    Don't tell us you want to fill the text box tell us what do you do with the information in the text box and how do you use it?

    To answer your specific question the following code is probably what you want

    Please Login or Register  to view this content.
    If the data sheet 'Game' was in a different layout so that it was a normalised 2 dimensional range with columns for
    Date
    Game
    Un.
    Custo/Un.

    then you'd be able to use Pivot Tables for all sorts of analysis and avoid macros or even formulae.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor
    Join Date
    07-15-2016
    Location
    Maputo, Mozambique
    MS-Off Ver
    2007
    Posts
    108

    Re: My first try with loops...but it is not working... explanation required!

    Hi Richard, thanks for aanswer me.
    The text box content is just for reading, and later there will be a couple of math operations with the prices values.

    I would like to avoid to show the database to user, instead I thought to use a textbox.
    This way i can have two textboxes on the main page with different data from a second data sheet and visually compare.

    I do not know another way to have two separate scroll-able windows/textxboxes in the same page....

    I changed the lines you indicated but still... I only get two zeros in the textbox...

  4. #4
    Valued Forum Contributor
    Join Date
    08-07-2014
    Location
    Quito, Ecuador
    MS-Off Ver
    Excel 2016 & 365, Windows 10
    Posts
    511

    Re: My first try with loops...but it is not working... explanation required!

    Hi @Alex Piotto
    You can give a try to this code

    Please Login or Register  to view this content.
    Last edited by vichopalacios; 04-11-2018 at 10:14 AM.
    Barriers are there for those who don't want to dream

  5. #5
    Forum Contributor
    Join Date
    07-15-2016
    Location
    Maputo, Mozambique
    MS-Off Ver
    2007
    Posts
    108

    Re: My first try with loops...but it is not working... explanation required!

    Hi vichopalacios
    thanks for your time and the dedication.
    Your code works fine.
    What I unfortunately noticed is that the tabs distances get messy.... and i imagine it is impossible to put the contents of the textbox organized by column as in an activex listbox.
    So i tried an activex listbox... to discover that the very moment i try to use the mouse wheel to scroll, it makes excel crash.

    The other listbox, the excel one, do not scroll but at list do not crash.

    It is possible to have columns of data organized in a standard listbox as in an activex one?

    The all purpose of the code is, in the end, to have two lists of items visible at the same time on the sheet, with the possibility to scroll them separately without scrolling the page.
    This way the user can watch and visually compare two lists...

    Any idea?

  6. #6
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: My first try with loops...but it is not working... explanation required!

    Instead of placing objects on the worksheet try creating a user form and putting your objects there instead
    - in my experience that gives fewer problems
    Last edited by kev_; 04-11-2018 at 12:09 PM.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  7. #7
    Forum Contributor
    Join Date
    07-15-2016
    Location
    Maputo, Mozambique
    MS-Off Ver
    2007
    Posts
    108

    Re: My first try with loops...but it is not working... explanation required!

    You are right, kev.
    In fact i just inserted a listbox-x into a userform and it is not crashing... nor scrolling as a matter of fact.
    I could use a big form and accommodate the two listboxes in there, but there is the border and the close button of the userform that are not required... any sugestion about it?

  8. #8
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: My first try with loops...but it is not working... explanation required!

    Make everything smaller - font sizes, box sizes and fit in more data
    You could use 2 userforms and toggle between the 2 to give you more space

+ 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. Testing if an object exists... explanation required
    By anrichards22 in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 12-28-2017, 06:10 AM
  2. [SOLVED] explanation required for HD serial no same on 3 different pc
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-26-2017, 10:06 AM
  3. VBA explanation required
    By ntljennifer in forum Excel General
    Replies: 2
    Last Post: 06-27-2014, 09:05 PM
  4. Multi Level Dependent Drop-down list, Explanation required
    By Shoieb.arshad in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-31-2012, 11:36 AM
  5. if else loops excel vba code required
    By razwan1978 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-09-2009, 03:10 AM
  6. A better explanation of help required
    By Elvey in forum Excel General
    Replies: 3
    Last Post: 05-20-2006, 12:28 PM
  7. Simple explanation of formula required pls
    By Swn-Y-Mor in forum Excel General
    Replies: 4
    Last Post: 01-14-2005, 08:48 AM

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