hi there
I need to display the data from a list of named cells (NameCells) when there is a value for that specific cell.

here is my code
VB Code:
  1. Private Sub PrintTest()
  2.     Dim xlApp As Object
  3.     Dim xlWkBk As Object
  4.     Dim xlSheet As Object
  5.     Dim filePath As String
  6.    
  7.     Dim NameVal As String
  8.     Dim DescVal As String
  9.     Dim DeptVal As String
  10.     Dim Purpose As String
  11.        
  12.     ' set values
  13.     NameVal = "AirCon1"
  14.     DescVal = " Air Con"
  15.     DeptVal = "IT"
  16.     PurposeVal = ""
  17.    
  18.     filePath = "c:\Test Excel\Test.xls"
  19.     Set xlApp = CreateObject("Excel.Application")
  20.     Set xlWkBk = xlApp.Workbooks.Open(filePath)
  21.     Set xlSheet = xlWkBk.Worksheets(1)
  22.    
  23.     With xlSheet
  24.    
  25.        
  26.         If NameVal <> Null Then
  27.              
  28.             '.Range(get from the NamedCell).Value = NameVal
  29.            
  30.          End If
  31.      
  32.         ' and so on
  33.      
  34.      End With
  35.     xlWkBk.PrintOut
  36.     xlWkBk.Close SaveChanges:=False
  37.     xlApp.Quit
  38.     Set xlSheet = Nothing
  39.     Set xlWkBk = Nothing
  40.     Set xlApp = Nothing
  41.    
  42. End Sub
  43.  
  44. Private Sub NamedCell(TemplatePath As String, _
  45.                                 Name As String, _
  46.                                 Desc As String, _
  47.                                 Dept As String, _
  48.                                 Purpose As String)
  49.  
  50.                                
  51. Const NamedCell_Name As String = "Name"
  52. Const NamedCell_Desc As String = " Desc"
  53. Const NamedCell_Dept As String = " Dept"
  54. Const NamedCell_Purpose As String = " Purpose"
  55.  
  56. End Sub