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:
visual basic code:--------------------------------------------------------------------------------Public FileName As String [Highlight=VB]Public FileName2 As String Public length As Integer Public Length2 As Integer 'Public xlApp As Object Public xlApp As Excel.Application Public wkbobj As Excel.Workbook Public xlstart As Excel.Worksheet Public xloutput As Excel.Worksheet
In form
visual basic code:----------------------------------------------------------------------------------------------------------------------------------------------------------------[/Highlight]VB Code:
Dim FileLength As Long Dim i As Long Dim arraydata() As String Dim x As Integer Dim columns As Integer Dim j As Integer Dim FirstGap As Integer Dim desc As String Dim pos As Integer Dim mywbook As String Dim thiscell As String Dim thiscell2 As String 'Striping out the path to get the filename frmEBS.txtFileName.Text = FileName pos = InStrRev(FileName, "\") mywbook = Mid(FileName, pos + 1, Len(FileName) - pos + 1) Set xlApp = Excel.Application Set wkbobj = xlApp.Workbooks(mywbook) Set xlstart = wkbobj.Sheets("Starting point") xlstart.Range("A2").Copy 'Worksheets("Output1").Activate - taken out xloutput.Range("C2").PasteSpecial xloutput.Range("e2").PasteSpecial ' From here program getting confused thiscell2 = xloutput.Cells(2, 5) If Left(thiscell2, 2).Text = "ND" Or _ Left(thiscell2, 2).Text = "SD" Or _ Left(thiscell2, 2).Text = "EBS" Then 'Don't do anything Else xloutput.Cells(2, 5) = "EBS-" & thiscell2 End If xloutput.Cells(2, 5).Copy ' copy one one description to the next description xloutput.Range("i2").PasteSpecial
Cheers,
B




Reply With Quote