help importing data

john smithmyer

New Member
Joined
Nov 29, 2008
Messages
45
I have a data source with 20 fields. I created an export “template” that exports 8 of the 20 fields to a tab delimited text file.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p></o:p>
I also have an Excel spreadsheet (with visual basic code) that imports this data ( 8 fields) and processes it into a report.<o:p></o:p>
<o:p></o:p>
The eight fields are:<o:p></o:p>
Date 05/26/2012<o:p></o:p>
View Good<o:p></o:p>
Temp 78<o:p></o:p>
Size 8<o:p></o:p>
Cap Yes<o:p></o:p>
Bad No<o:p></o:p>
Run Yes<o:p></o:p>
Color Red, Blue, Green<o:p></o:p>
<o:p></o:p>
When exported from the data source, if Color has more than one entry it creates duplicate fields for each one like this:<o:p></o:p>
Date View Temp Size Cap Bad Run Color Color Color<o:p></o:p>
05/26/12 Good 78 8 Yes No Yes Red Blue Green<o:p></o:p>
<o:p></o:p>
Any ideas on how I can import this data into my Excel application which would combine the “like” fields into one before processing?<o:p></o:p>
<o:p></o:p>
Thanks as always for your kind assistance!<o:p></o:p>
<o:p></o:p>
John<o:p></o:p>
 
Funny enough, I get the same error.

I don't get it!

Again, thanks for your very kind help in finding a solution to this problem.

Best Regards,
John
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
It may have to do with how you are brining the data in (it looks like you may be linking instead of importing). Maybe it thinks you are trying to update the original data source and doesn't like that.

What iof you trying importing your file instead?
 
Upvote 0
Joe,

Thanks for your continued help.

I think I have an idea. My imported data runs from column A to M.

I also have data and formulas from column O to Z.

How could your code be altered to only go to coulmn M rather than to the last coulmn.

I think your code is getting messed up by stuff in columns O to Z.

Does that make sence?
 
Upvote 0
Maybe this (new lines highlighted in red)?
Code:
Sub FixData()
 
    Dim myLastRow As Long
    Dim myLastCol As Long
    Dim myRow As Long
    Dim myCol As Long
    Dim myString As String
 
    Application.ScreenUpdating = False
 
'   Find last row of data
    myLastRow = Cells(Rows.Count, "A").End(xlUp).Row
 
'   Loop through each row
    For myRow = 1 To myLastRow
'   Find last column of data
        myLastCol = Cells(myRow, Columns.Count).End(xlToLeft).Column
'   If goes past column H, combine last columns
        If myLastCol > 8 Then
            myString = ""
            [COLOR=red]If myLastCol > 13 Then myLastCol = 13[/COLOR]
            For myCol = 8 To myLastCol
                [COLOR=red]If Len(Cells(myRow, myCol)) > 0 Then[/COLOR]
                    myString = myString & Cells(myRow, myCol) & ","
                [COLOR=red]End If[/COLOR]
            Next myCol
            Cells(myRow, 8) = Left(myString, Len(myString) - 1)
            Range(Cells(myRow, 9), Cells(myRow, myLastCol)).ClearContents
        End If
    Next myRow
 
    Application.ScreenUpdating = True
 
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,587
Messages
6,120,406
Members
448,958
Latest member
Hat4Life

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top