?
Solved

skip field on import

Posted on 2003-03-29
4
Medium Priority
?
150 Views
Last Modified: 2010-05-01
i have the following code but i want to not import the first field and the 5th field
is this possible?

Dim fso As New FileSystemObject
  Dim ts As TextStream
  Dim rowNo As Integer
  Dim i As Integer
  Dim xlRow() As String
  Dim xla As Excel.Application
  Dim xlw As Excel.Workbook
  Dim xls As Excel.Worksheet
 
  Set xla = CreateObject("Excel.Application")
  Set xlw = xla.Workbooks.Add
  Set xls = xlw.Sheets("Sheet1")
  rowNo = 1
  xla.Visible = False

  Set ts = fso.OpenTextFile("c:\test\file.txt")
  Do While ts.AtEndOfStream <> True
      xlRow = Split(ts.ReadLine, ",", -1, vbTextCompare)
      For i = 0 To UBound(xlRow)
          xlRow(i) = Replace(xlRow(i), Chr(34), "")
          xls.Cells(rowNo, i + 1) = xlRow(i)
      Next i%
      rowNo = rowNo + 1
  Loop
  ts.Close
 
  xlw.SaveAs ("c:\test\file.xls")
  xla.Quit
  Set xla = Nothing
0
Comment
Question by:Marcusw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
jyokum earned 1000 total points
ID: 8232658
For i = 0 To UBound(xlRow)
   if not i = 0 and not i = 4 then
       xlRow(i) = Replace(xlRow(i), Chr(34), "")
       xls.Cells(rowNo, i + 1) = xlRow(i)
   end if
Next i%
0
 

Expert Comment

by:CleanupPing
ID: 8531345
Hi Marcusw,
This old question (QID 20567693) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
 
LVL 12

Expert Comment

by:jyokum
ID: 9301540
Marcusw,
This has been open 161 days and there hasn't been a comment added in 114 days.
Please select a comment as the solution or give us an update.
0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 9440691
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

 -->Accept jyokum's comment as Answer

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER

GPrentice00
Cleanup Volunteer
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question