Hi,

I am trying to avoid using the Rang("a3").activate method to activatre a reference cell. I have started uisng object variables.

Have some code here which says when run object required.

Can someone help debug the code ammendments and where I am going wrong.

Just copying and pasting between cells and using some text string statements. The routine is getting
to the left statements below and becoming unstuck - please see the find the comment where error occurred:-


' From here program getting confused


In module


VB Code:
  1. visual basic code:--------------------------------------------------------------------------------Public FileName As String
  2. [Highlight=VB]Public FileName2 As String
  3. Public length As Integer
  4. Public Length2 As Integer
  5. 'Public xlApp As Object
  6. Public xlApp As Excel.Application
  7. Public wkbobj As Excel.Workbook
  8. Public xlstart As Excel.Worksheet
  9. Public xloutput As Excel.Worksheet
--------------------------------------------------------------------------------



In form


visual basic code:--------------------------------------------------------------------------------
VB Code:
  1. Dim FileLength As Long
  2. Dim i As Long
  3. Dim arraydata() As String
  4. Dim x As Integer
  5. Dim columns As Integer
  6. Dim j As Integer
  7. Dim FirstGap As Integer
  8. Dim desc As String
  9. Dim pos As Integer
  10. Dim mywbook As String
  11. Dim thiscell As String
  12. Dim thiscell2 As String
  13.  
  14. 'Striping out the path to get the filename
  15.  
  16. frmEBS.txtFileName.Text = FileName
  17. pos = InStrRev(FileName, "\")
  18. mywbook = Mid(FileName, pos + 1, Len(FileName) - pos + 1)
  19.  
  20.  
  21. Set xlApp = Excel.Application
  22. Set wkbobj = xlApp.Workbooks(mywbook)
  23. Set xlstart = wkbobj.Sheets("Starting point")
  24.  
  25.  
  26. xlstart.Range("A2").Copy
  27. 'Worksheets("Output1").Activate - taken out
  28. xloutput.Range("C2").PasteSpecial
  29. xloutput.Range("e2").PasteSpecial
  30.  
  31.  
  32. ' From here program getting confused
  33.  
  34. thiscell2 = xloutput.Cells(2, 5)
  35. If Left(thiscell2, 2).Text = "ND" Or _
  36.    Left(thiscell2, 2).Text = "SD" Or _
  37.    Left(thiscell2, 2).Text = "EBS" Then
  38.    'Don't do anything
  39.    
  40. Else
  41. xloutput.Cells(2, 5) = "EBS-" & thiscell2
  42. End If
  43. xloutput.Cells(2, 5).Copy ' copy one one description to the next description
  44. xloutput.Range("i2").PasteSpecial
--------------------------------------------------------------------------------[/Highlight]


Cheers,
B