+ Reply to Thread
Results 1 to 3 of 3

Write validation info to a Cell

Hybrid View

  1. #1
    Registered User
    Join Date
    08-16-2012
    Location
    Almere
    MS-Off Ver
    Excel 2003
    Posts
    48

    Write validation info to a Cell

    I know how to write data (xxx) to the first available empty cel in kolom A on a worksheet by using this code below:
    Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Offset(1, 0) = xxx
    I also found a piece of code that writes Validation to a specific Cell
    Sub Add_Cell_Input_Message_Cell()
    
    With Range("A1").Validation
    .Add Type:=xlValidateInputOnly
    .InputTitle = "Message Title Goes Here"
    .InputMessage = "Message Contents Go Here"
    End With
    
    End Sub
    Is it possible to combine these two codes so that data xxx is written to the next available cell in kolom A on a worksheet AND write the validation info to the same cell also ???

  2. #2
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Write validation info to a Cell

    Try this, not sure it will work though and change the validation settings
    Sub validation()
    Dim r As Range
    Set r = Worksheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
    With r.Validation
    .Add Type:=xlValidateInputOnly
    .InputTitle = "Message Title Goes Here"
    .InputMessage = "Message Contents Go Here"
    End With
    r.Value = "xxx"
    End Sub
    Last edited by stojko89; 09-04-2012 at 08:23 AM. Reason: Code Edit

  3. #3
    Registered User
    Join Date
    08-16-2012
    Location
    Almere
    MS-Off Ver
    Excel 2003
    Posts
    48

    Re: Write validation info to a Cell

    Stojko89, thx for this. It gave me some little errors but I was able to resolve them myself.
    The code is working excellent now

+ 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