Try this

Sujit Patil replied to milinda nath at 04-Jul-08 06:30

May be this will help you;

Imports Excel = Microsoft.Office.Interop.Excel
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles Button1.Click

        Dim xlApp As Excel.Application
        Dim xlWorkBook As Excel.Workbook
        Dim xlWorkSheet As Excel.Worksheet
        Dim misValue As Object = System.Reflection.Missing.Value
        Dim rangeCells As Excel.Range

        xlApp = New Excel.ApplicationClass
        xlWorkBook = xlApp.Workbooks.Add(misValue)
        xlWorkSheet = xlWorkBook.Sheets("sheet1")

        xlWorkSheet.Range("B5", "D5").Validation.Add( _
        Type:=Excel.XlDVType.xlValidateInputOnly, _
        AlertStyle:=Excel.XlDVAlertStyle.xlValidAlertStop, _
        Operator:=Excel.XlFormatConditionOperator.xlBetween)
        xlWorkSheet.Range("B5", "D5").Validation.IgnoreBlank = True
        xlWorkSheet.Range("B5", "B5").FormulaR1C1 = "Click  Here " + _
        "to see Notes"
        xlWorkSheet.Range("B5", "D5").Validation.InputTitle = _
        "vb.net-informations.com"
        xlWorkSheet.Range("B5", "D5").Validation.ErrorTitle = "Error in Title"
        xlWorkSheet.Range("B5", "D5").Validation.InputMessage = "Here is " + _
        " the notes  embeded - you can enter 255 characters maximum in notes "
        xlWorkSheet.Range("B5", "D5").Validation.ErrorMessage = "Error in Notes"
        xlWorkSheet.Range("B5", "D5").Validation.ShowInput = True
        xlWorkSheet.Range("B5", "D5").Validation.ShowError = True

        xlWorkSheet.SaveAs("C:\vbexcel.xlsx")
        xlWorkBook.Close()
        xlApp.Quit()

        releaseObject(xlApp)
        releaseObject(xlWorkBook)
        releaseObject(xlWorkSheet)

        MsgBox("File created !")
    End Sub

    Private Sub releaseObject(ByVal obj As Object)
        Try
            System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
            obj = Nothing
        Catch ex As Exception
            obj = Nothing
        Finally
            GC.Collect()
        End Try
    End Sub
End Class


Go thr these links for more details;
http://vb.net-informations.com/excel-2007/vb.net_excel_data_validation_input_message.htm
http://vb.net-informations.com/excel-2007/vb.net_excel_inset_data_oledb.htm
Best Luck!!!!!!!!!!!!!
Sujit.

Click here to sign in and reply. You could earn money via our $500 contest just for being helpful.
  validate excel data before inserting to sql database - milinda nath  04-Jul-08 06:18 6:18:40 AM
      Try this - Sujit Patil  04-Jul-08 06:30 6:30:17 AM
          validate data in excel - milinda nath  04-Jul-08 07:11 7:11:14 AM
      excel validation - Partha Mandayam  04-Jul-08 06:34 6:34:20 AM
      Try these links - santhosh kumar  04-Jul-08 07:22 7:22:36 AM
      validate - sundar k  04-Jul-08 08:04 8:04:35 AM
      Re : validate excel data before inserting to sql database - Ashutosh Dhok  04-Jul-08 08:06 8:06:41 AM
View Posts