Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ammend Add to column.

Status
Not open for further replies.

paulk11

IS-IT--Management
Oct 11, 2007
11
GB
After a whole weekend of headscratching finaly got the below to work in VBS.

Trouble is this overwrites the data already in column A as opposed to just adding to it. any body have any any anmmendments nessasry to make so this dosnt happen.

Paul


Dim i, objfso, objfile, strline, arrline, aFile
Const ForReading = 1
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
oExcel.Workbooks.Open("D:\get-group\GroupMembers.csv")
Set oSheet = oExcel.ActiveWorkbook.Worksheets(1)
oExcel.DisplayAlerts = FALSE
'objExcel.Workbooks.Add
i = 1
set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("D:\get-group\New-Stu-Passwords.txt", ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
arrLine = Split(strLine, ",")
oExcel.Cells(i, 1).Value = arrLine(0)
i = i + 1
Loop
oExcel.ActiveWorkbook.Saveas ("D:\get-group\New-Stu-Passwords.csv")
objFile.Close
oExcel.Quit
 
Try
Code:
oExcel.Cells(i, 1).Value = oExcel.Cells(i, 1).Value & " " & arrLine(0)
[code]

This will append the arrLine(0) string to the existing string value of the cell.


Everybody is somebodys Nutter.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top