• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

I have a stupid question

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    #11
    The function as it is at the moment only works properly if the data looks like a postcode.

    AA1 1AA returns false
    SW1 1AA returns true
    AAAA gives an error.

    So you'll need some sort of error handling if you're going to use it in anger.

    Comment


      #12
      try buying something like postcode anywhere. That will correct your address as well.

      postcodes are far too much fun to try and keep up with.
      Always forgive your enemies; nothing annoys them so much.

      Comment


        #13
        It works Thanks for all your help guys - really appreciated
        Connect with me on LinkedIn

        Follow us on Twitter.

        ContractorUK Best Forum Advisor 2015

        Comment


          #14
          Originally posted by LisaContractorUmbrella View Post
          It works Thanks for all your help guys - really appreciated
          That's good. And do you understand it now?

          Comment


            #15
            Originally posted by mudskipper View Post
            That's good. And do you understand it now?
            Absolutely
            Connect with me on LinkedIn

            Follow us on Twitter.

            ContractorUK Best Forum Advisor 2015

            Comment


              #16
              Morning -sorry to be a bother but I have a teeny problem with this now

              The calculation incorporating the expression works perfectly except when I come to incorporate it in a macro - what have I missed???

              Sub Postcode()
              '
              ' Postcode Macro
              ' Macro4
              '

              '
              Columns("P:P").Select
              Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
              Range("P2").Select
              ActiveCell.FormulaR1C1 = "=IF(ValidPostCode(RC[-1]),""OK"",""Incorrect"")"
              Range("P3").Select
              End Sub
              Connect with me on LinkedIn

              Follow us on Twitter.

              ContractorUK Best Forum Advisor 2015

              Comment


                #17
                Sorry, missed your email.

                Assuming you want a macro to insert a new column in column P (data being in column O), then validate the post codes using the function, try

                Code:
                Sub PostCode()
                    Range("P1").Select
                    Selection.EntireColumn.Insert
                    ActiveCell.FormulaR1C1 = "=IF(ValidPostCode(RC[-1]),""OK"",""Incorrect"")"
                    Range("P1").Select
                    Selection.Copy
                    Range("O1").Select
                    Selection.End(xlDown).Select
                    ActiveCell.Offset(0, 1).Activate
                    Range(Selection, Selection.End(xlUp)).Select
                    ActiveSheet.Paste
                    Application.CutCopyMode = False
                End Sub
                That would stop if there are any blanks in the column, though.
                Best Forum Advisor 2014
                Work in the public sector? You can read my FAQ here
                Click here to get 15% off your first year's IPSE membership

                Comment


                  #18
                  No worries TF - thanks for posting

                  Nope still doesn't work. The macro just returns a blank in the field that I would expect to find the formula
                  Connect with me on LinkedIn

                  Follow us on Twitter.

                  ContractorUK Best Forum Advisor 2015

                  Comment


                    #19
                    Originally posted by LisaContractorUmbrella View Post
                    No worries TF - thanks for posting

                    Nope still doesn't work. The macro just returns a blank in the field that I would expect to find the formula
                    I've emailed you my spreadsheet
                    Best Forum Advisor 2014
                    Work in the public sector? You can read my FAQ here
                    Click here to get 15% off your first year's IPSE membership

                    Comment


                      #20
                      Originally posted by TheFaQQer View Post
                      I've emailed you my spreadsheet
                      You're the best
                      Connect with me on LinkedIn

                      Follow us on Twitter.

                      ContractorUK Best Forum Advisor 2015

                      Comment

                      Working...
                      X