tags:

views:

179

answers:

4
A: 

I rarely code in VBA/VB but... Something like

Dim rngAwayTeam As Range, rngHomeTeam As Range
set rngAwayTeam = Worksheets("YourWorksheet").Range("C2")
set rngHomeTeam = Worksheets("YourWorksheet").Range("D2")
Dim rowOffset As Integer
rowOffset = 1
Do While (rngAwayTeam.Offset(rowOffset,1).Text <> "") 
  'Do something with rngAwayTeam.Offset(rowOffset,1).Text
  'and rngHomeTeam.Offset(rowOffset,1).Text
  rowOffset = rowOffset + 1
Loop

There are other ways I'm sure, but, here is what I would do.

Is this an excel macro? would it be better to use C# so i can use the data classes to easily update my db?
masfenix
A: 

Yes that is an excel macro. Again, I rarely use VBA or .Net, just trying to help you out the best I can. You could just use a C# COM object for the database side of things. (Still new, can't comment.)

Hameltime
A: 

You can do it in C# console application quite easily. All you have to do is loop through each line in the file, adding it to an array using split on the comma (,).

Then you can use your array to display the values or retrieve a specific value on a row.

waqasahmed
+3  A: 

One line of PowerShell will read in the CSV file and create a custom object for each home and away team listing (with a property for the city name and for the team name). The last command in the pipeline will eliminate the duplicates.

$TeamsAndCities = import-csv -path c:\mycsvfile.csv | foreach-object { $_.away, $_.home | select-object @{Name='City';Expression={$_.split(' ')[0]}}, @{Name='Team';Expression={$_.split(' ')[1]}} } | select-object -unique

You can do database access from PowerShell as well, but that might be suited to a new question with some more details about the database you are connecting to.

Steven Murawski