+ Reply to Thread
Results 1 to 4 of 4

Solving "Type miss match problem in For ..... Next

Hybrid View

  1. #1
    Registered User
    Join Date
    08-19-2019
    Location
    Sudan
    MS-Off Ver
    10
    Posts
    1

    Question Solving "Type miss match problem in For ..... Next

    Being a new user of Excel programing I faced the following problem:
    I have a text Box named txtPayeeName repeated in a Form 4 times, (txtPayeeName , txtPayeeName1, txtPayeeName2, txtPayeeName3).
    I want to hide the three TextBoxes and leave the first on visible.
    I tried to use For ...Next, but I always get "Type Miss Match" error.
    this is what I tried:

    For X = 1 To 4 Step 1
        txtPayeeName (x).Text.Visible=False
        x = x +1
    Next
    I expected it to Read as follows:
    txtPayeeName1.Text.Visible = False
    txtPayeeName2.Text.Visible = False
    txtPayeeName3.Text.Visible = False

    So, can anyone show the mistake I made and the correction.
    Last edited by 6StringJazzer; 08-19-2019 at 08:49 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2404
    Posts
    24,757

    Re: Solving "Type miss match problem in For ..... Next

    Your code looks like a shot in the dark. There are multiple problems with your code. Not sure how you came up with that. Rather than listing problems, here is untested code I think will work. If not please attach your file.

    For X = 1 To 3
        Controls("txtPayeeName" & X).Visible=False
    Next X
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486

    Re: Solving "Type miss match problem in For ..... Next

    At first glance, there is not "txtPayeeName4"

  4. #4
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,743

    Re: Solving "Type miss match problem in For ..... Next

    You don't have textbox4 so you can't looping to 4.
    For x = 1 To 3
        ActiveSheet.Shapes("TextBox" & x).Visible = False
    Next
    Last edited by KOKOSEK; 08-19-2019 at 08:58 AM.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

+ 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] solving a type mismatch in expression" error
    By Juli in forum Access Tables & Databases
    Replies: 9
    Last Post: 04-21-2019, 04:25 PM
  2. Countifs type miss-match...Why?
    By biznez in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-03-2016, 03:48 PM
  3. Replies: 4
    Last Post: 11-17-2013, 12:05 PM
  4. Got a "Type miss Match" Error when search one specific word
    By tantcu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-28-2013, 01:22 PM
  5. excel runtime error 13; type miss match
    By terrysoper1973 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-01-2012, 12:13 PM
  6. type miss match
    By newapa in forum Excel General
    Replies: 1
    Last Post: 09-24-2012, 01:30 PM
  7. Miss-wrote previous "IF" problem
    By gbeard in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-14-2005, 07:06 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