Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default csv info to excel

I am brand new to VBA and have a beginner level knowledge of Visual Basic 6.0

I was assigned a task recently for Excel that exceeds my knowledge of VBA and Excel by far.


what i need to do is make an existing file read a .csv file and add the quantity.

for example.

Excell File.

Item Number | Description | Quantity |
0003635457 | Vcr's | 0 |
8848483748 | DVD | 3 |
8837267499 | Reciever | 14 |
etc.

..csv File.

ItemNumber, Quantity
83836464985, 4
83984959489, 12
28498748793, 9
etc.

i want to search the csv file for each ItemNumber (I know how to do basic Naming of Cells) and then update the quantity in the Excell file.

I'd also like to say I am not one of these people too incompetent to learn, I am learning VBA now from the beginning, but I just have a deadline with this particular task. hehe.

Any help would be greatly appreciated
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default csv info to excel

This might get you started:

Option Explicit
Sub testme()

Dim myRng As Range
Dim myCell As Range
Dim curWks As Worksheet
Dim csvRng As Range
Dim res As Variant

Set curWks = ActiveSheet
Set csvRng = Workbooks.Open(Filename:="C:\my documents\excel\book5.csv") _
.Worksheets(1).Range("a:a")

With curWks
Set myRng = .Range("a2", .Cells(.Rows.Count, "A").End(xlUp))
For Each myCell In myRng.Cells
res = Application.Match(myCell.Value, csvRng, 0)
If IsError(res) Then
'no match found
Else
If IsNumeric(csvRng(res).Offset(0, 1).Value) _
And IsNumeric(myCell.Offset(0, 2)) Then
myCell.Offset(0, 2).Value _
= myCell.Offset(0, 2).Value _
+ csvRng(res).Offset(0, 1).Value
Else
MsgBox "nonnumeric data in: " & myCell.Row & _
vbLf & "or in the CSV file line: " & res
End If
End If
Next myCell
End With

csvRng.Parent.Parent.Close savechanges:=False
End Sub


Thomas DeFrank wrote:

I am brand new to VBA and have a beginner level knowledge of Visual Basic 6.0

I was assigned a task recently for Excel that exceeds my knowledge of VBA and Excel by far.

what i need to do is make an existing file read a .csv file and add the quantity.

for example.

Excell File.

Item Number | Description | Quantity |
0003635457 | Vcr's | 0 |
8848483748 | DVD | 3 |
8837267499 | Reciever | 14 |
etc.

.csv File.

ItemNumber, Quantity
83836464985, 4
83984959489, 12
28498748793, 9
etc.

i want to search the csv file for each ItemNumber (I know how to do basic Naming of Cells) and then update the quantity in the Excell file.

I'd also like to say I am not one of these people too incompetent to learn, I am learning VBA now from the beginning, but I just have a deadline with this particular task. hehe.

Any help would be greatly appreciated


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
i deleted info in excel then saved. can i recover deleted info? jbhtbruce Excel Discussion (Misc queries) 2 May 25th 10 08:54 AM
Copied info from Excel worksheet, but pasted info won't work in fo KRISTENV Excel Discussion (Misc queries) 3 January 8th 09 03:13 PM
Link info in one cell to info in several cells in another column (like a database) hansdiddy Excel Discussion (Misc queries) 1 February 22nd 06 02:27 AM
Can I lock info in Excel 2003 and users in Excel 2000 enter info? Mimmsan Excel Discussion (Misc queries) 1 September 8th 05 12:12 AM
how do i get excel to see info in one cell, look at info in anoth. ditto Excel Discussion (Misc queries) 3 February 1st 05 04:37 PM


All times are GMT +1. The time now is 08:30 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"