+ Reply to Thread
Results 1 to 9 of 9

Amend an if statement

  1. #1
    Registered User
    Join Date
    05-21-2008
    Posts
    24

    Amend an if statement

    Hi,

    I need to make this code work for every line in column A and column F. Whats the easiest way of doing this?

    Please Login or Register  to view this content.
    Thanks!

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    This perhaps.
    Please Login or Register  to view this content.

  3. #3
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481
    Hi Tracer,

    You can use this code it you don't know the maximum number of rows on your worksheet:

    Please Login or Register  to view this content.
    Hope this helps. Please let me know how you get on.

    Regards,

    Greg M

  4. #4
    Registered User
    Join Date
    05-21-2008
    Posts
    24
    I decided to try it this way, so that the people using it don't have to run the macro. I keep getting the #VALUE! error though...
    Please Login or Register  to view this content.
    Cell "A2" = "PD93-L-1000-1"
    Cell "F2" = "=GetDocumentType(A2)"

    What am I doing wrong?

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Well you've now changed from a Sub to a Function, specifically a user defined worksheet that you seem to be trying to use on a worksheet.

    Firstly you aren't returning any value with the function and secondly you don't actually seem to be doing much with the parameter DocumentType.

    Did you try any of the other code posted?

  6. #6
    Registered User
    Join Date
    05-21-2008
    Posts
    24
    Quote Originally Posted by Norie
    Well you've now changed from a Sub to a Function, specifically a user defined worksheet that you seem to be trying to use on a worksheet.

    Firstly you aren't returning any value with the function and secondly you don't actually seem to be doing much with the parameter DocumentType.

    Did you try any of the other code posted?
    Yes I did try the other code and it works, but I wanted to try it this way so that they dont have to run the macro. DocumentType will just be a cell value to replace the "For iRow = 2 To ActiveSheet.Range("A65536").End(xlUp).Row" that Greg mentioned.

    So F2,F3,F4... for me will be:
    =GetDocumentType(A2)
    =GetDocumentType(A3)
    =GetDocumentType(A4)
    etc...

    What do you mean by the bolded part?

  7. #7
    Registered User
    Join Date
    05-21-2008
    Posts
    24
    Found my mistake... I'm an idiot

  8. #8
    Registered User
    Join Date
    04-24-2008
    Location
    Zurich
    Posts
    45
    The Code should read:
    Please Login or Register  to view this content.

  9. #9
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481
    Hi Tracer,

    Glad to hear that things are working for you. Thanks for the feedback.

    Regards,

    Greg M

+ 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