+ Reply to Thread
Results 1 to 21 of 21

Compile error user defined type not define

  1. #1
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Compile error user defined type not define

    Dear friends,
    I'm unable to code the tag so I deleted it and attached a file for your kind reference. Please give me a solution.

    Thanking you in anticipation.

    Mukesh
    Attached Files Attached Files
    Last edited by mukeshbaviskar; 11-12-2013 at 01:47 AM. Reason: unable to code tags

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Compile error user defined type not define

    Try adding a reference to OutLook using the Tools/References menu - if that doesn't work then try mentioning where the problem is flagged by the compiler...

    To add code tags, highlight the code and click the '#' button on the toolbar.

  3. #3
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: Compile error user defined type not define

    Hi cytop,
    I'm unable to quote the code tag so I deleted the code and attached a file for yor kind reference. I have already checked 'Microsoft office 12.1 object library' but the error is same.

    Please go through it and give me a solution and hint to avoide such error again in future.

    Thank you.

    Mukesh

  4. #4
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Compile error user defined type not define

    Sorry - I'm not going to debug your code for you. I said in my last post that you should
    ...try mentioning where the problem is flagged by the compiler.
    Once you provide all the relevant information then it will be time to look at the workbook if the issue is still not obvious.
    Last edited by cytop; 11-12-2013 at 04:16 AM. Reason: Typo

  5. #5
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: Compile error user defined type not define

    Hi CYTOP,
    The problem is in the first line of code itself. Please look it and give me a solution positively.

    Waiting to receive a concrete solution from you eagerly.

    Thank you.

    Mukesh

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Compile error user defined type not define

    Hi, Mukesh,

    there is no reference for Outlook set in the sample Workbook. You would need to set that, then try the code again and you will receive another error.

    You should really take some of the basics of writing/working on code. As you are pretty new to VBA I strongly recommend to put each command on a line of itīs own instead of using multiple commands in one line. And you should work with proper indention on the code so that you should have noted that there is an End If missing. Further on you donīt have a sheet Personal in the workbook.

    pRow isnīt dimmed nor initialized so it holds a value of 0 and will cause another error - a very strong argument to work with Option Explicit..

    Please Login or Register  to view this content.
    Mostly I wonder why you get code in your earlier threads that works and decide to sort of shredder these codes so they donīt work and then come back for help.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  7. #7
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: Compile error user defined type not define

    Hi Holger,
    Sorry and thank you for your kind guidance. The code was working fine in my earlier posts but it takes a long time to complete the task. It scrolls from top to bottom to find the birthday on that particular date. There are thousands of members in my file and takes a long time to find the birthday. So I planned to filter the date and run the macro on that visible rows only which will complete the task within a few seconds. After working and observing the working and output the new ideas comes in mind to make the macro more perfect, clean and time saving. So I work on it continuously and come to you if I didn't get the desire output. You may observed that the same macro is modified each time and giving more perfect output.

    I rename the sheet 'Personal' so the error will not come.

    Just give me a idea how to set the outlook reference set in the code because the same error is I'm facing each time. I inserted the code you suggested and it also giving same error.

    I like your advice to compile code in a single line to avoide error.

    Thank you for kind guidance to make me perfect. I learned the little vba from the forum and guidance of you well wishers.

    Thank you.

    Mukesh
    Attached Files Attached Files
    Last edited by mukeshbaviskar; 11-12-2013 at 10:29 AM. Reason: Attach a attachment

  8. #8
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: Compile error user defined type not define

    Hi Holger,
    Good! Now I corrected the code and run the macro with no error but the mails are not delivering. The macro is running successfully with no error.

    Now please see the attached file and give me advice to solve it.

    Thank you.

    Mukesh
    Attached Files Attached Files

  9. #9
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Compile error user defined type not define

    Hi, Mukesh,

    but the mails are not delivering
    One of the great features of the VBE is to use F8 and single step through the code to see why a condition isnīt met. You (or whoever did it) inserted
    Please Login or Register  to view this content.
    Maybe reflect on that line why on any birthday with that command no mail should be sent.

    Ciao,
    Holger
    Last edited by HaHoBe; 11-12-2013 at 01:21 PM.

  10. #10
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: Compile error user defined type not define

    Hi Holger,
    Good morning! Thank you. I edited the code and have a little progress. Now the mail is created but there is no email id in column 'z' which is in column 'm'. So the error is occurring. The code doesn't recognize the birthday of 'a' which is in row 9. It recognize only 3 birthdays 'b, I, l'. I didn't find the solution. I used f8 function but due to my visual problem I'm unable to find the error. f8 highlits the error line with yellow color. So I use f5 which shows the error with breaf description.

    Please guide me.

    Thank you.

    Mukesh
    Attached Files Attached Files

  11. #11
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Compile error user defined type not define

    Hi, Mukesh,

    even if the birthday is reckognized there wonīt be a valid email-address as this is located in Column M whereas you work on the range starting on Column O.

    Code for ThisWorkbook:
    Please Login or Register  to view this content.
    Code for a standard module (here Modul1):
    Please Login or Register  to view this content.
    You should consider to use the Autofilter for Column AF and use "Send mail" as criteria. Any further action could be to check the number of the last visible cell to find out if any birthdays are on that day and then use a For Each and loop through the visible cells by using SpecialCells(xlCellTypeVisible) in one Column.

    Ciao,
    Holger
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: Compile error user defined type not define

    Hi Holger,
    Excellent! This much I expect to speed up the task. It's working fine as per my desire. However I didn't understand the meaning of 'z' in this line:

    x = .Range("o8:Z" & .Cells(Rows.Count, "p").End(xlUp).Row + 1).Value

    What does this 'z' represents here?

    It's just for my knowledge. The problem is solved.

    Thank you for teaching and solving my problem with helpful tips to develop my skill.

    Mukesh

  13. #13
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Compile error user defined type not define

    Hi, Mukesh,

    inside a bracket with Range itīs the Column Name so you are referencing the Range starting with O8 and going to Z and the last used row.

    Thanks for the feedback.

    Ciao,
    Holger

  14. #14
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: Compile error user defined type not define

    Hi Holger,
    That means in our case it should be 'af' instead of 'z'?

    Please clarify.

    Thank you for guidance.

    Mukesh

  15. #15
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Compile error user defined type not define

    Hi, Mukesh,

    the data should have gone to OClumn Z when the code was written, right now itīs going over to Column AF. So basicly the answer is yes but I would avoid any hardcoding on the Columns and use the last used Column in Row 8 like
    Please Login or Register  to view this content.
    But that wonīt solve the problem of the email addresses not being included in the range you read into x.

    Ciao,
    Holger

  16. #16
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: Compile error user defined type not define

    Hello Holger,
    Thank you for explanation. Now this new code has no restriction of how many columns there are to the right.

    Thank you.

    Mukesh

  17. #17
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: Compile error user defined type not define

    Hi Holger,
    One more little problem. If there is no email id then I inserted a dash '-' sign in that cell. At this situation the program asks email id which I want to ignore by program. At this time the pop up message should pop up as follows:

    MsgBox x(i, 1) & "'s Birthday Today! & has empty E-mail address", 48

    How to insert this msg into the code?

    Thank you.

    Mukesh

  18. #18
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Compile error user defined type not define

    Hi, Mukesh,

    I donīt get why this message doesnīt pop up in your version. If I take the workbook, alter the birthday for the first 2 entries and delete the email in Column M for the first I get that message.

    You would need to clarify what else you want but again: this is not the problem on which you started the thread.

    Ciao,
    holger

  19. #19
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: Compile error user defined type not define

    Hi Holger,
    Sorry! I agree with you that it's not a subject of this thread but in this code I'm getting error which you could understand well because you have a idea of this program.

    For example:
    I inserted a dash sign in cell m9 where the email id is not available. Then the program gives a error. It creates a mail with a dash sign in a 'to' field and displays the mail.

    The requirement is that if the email id is not available then I insert a dash sign there for not keep the cell blank. In this situation the program should simply pop up the message 'Mr. a's birthday today! & has empty email address' and after clicking on ok continue till the end. In short the program should simply display a message with the name of a person and & has empty email address. Then continue till the end.

    If this problem is solved then there is no any issue to solve.

    I'm optimistic that you will definitely solve this problem and this will be the last post for this thread.

    Thank you very much.

    Regards,

    Mukesh
    Attached Files Attached Files
    Last edited by mukeshbaviskar; 11-14-2013 at 11:59 AM.

  20. #20
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Compile error user defined type not define

    Hi, Mukesh,

    Please Login or Register  to view this content.
    Ciao,
    Holger

  21. #21
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: Compile error user defined type not define

    Hi Holger,
    Good morning! Excellent! Now it's working fine as per my requirement.

    Really I appreciate you for your kind help and guidance.

    Thank you for solving my problem with perfect output.

    Regards,

    Mukesh

+ 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. Error message: "Compile error. User-defined type not defined"
    By freckles81 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 06-13-2012, 09:37 AM
  2. compile error - user defined type not defined
    By TMP123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-23-2010, 01:42 PM
  3. VB Compile Error - User-defined type not defined
    By dbwiz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-08-2010, 04:31 PM
  4. Error message: "Compile error. User-defined type not defined"
    By lottesfog in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-25-2007, 06:38 PM
  5. [SOLVED] Help: Compile error: type mismatch: array or user defined type expected
    By lvcha.gouqizi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2005, 05:05 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