Advertisement

10.08.2008 at 08:33AM PDT, ID: 23797714 | Points: 500
[x]
Attachment Details

VB 256 column limit fix from microsofts website...trying to get it to work

Asked by allwebnow in Microsoft Excel Spreadsheet Software, VB Controls

Tags: , , ,

Ok,

Microsoft has a supposed fix for the 256 column limit here:
http://support.microsoft.com/kb/272729

I've gotten the code installed in my excel but i can't get it to work (it just sits there and does nothing saying importing row 1).  So,  i have 2 questions:

1. can someone help me get the VB code below to work with a "tab delimited" csv/txt file.
2. can someone help me to get the VB code to stay installed for my client on their excel software.  ie. everytime I reload excel, the macro is gone.  I just need to find out if it's possible to have it stay installed.

Ok, here's the VB Code from MS website.  I changed comma=true to false and changed tab=False to tab=True,  but that didn't work either.  I notice there is commacount everywhere...do I change this to tabcount?  I dont' know anything about VB so, please bare with me.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
Sub LargeDatabaseImport()
 
    'In the event of an error, make sure the application is reset to
    'normal.
    On Error GoTo ErrorCheck
 
    'Dimension Variables
    Dim ResultStr As String
    Dim FileName As String
    Dim FileNum As Integer
    Dim Counter As Double
    Dim CommaCount As Integer
    Dim WorkResult As String
 
    'Ask for the name of the file.
    FileName = InputBox("Please type the name of your text file, for example, test.txt")
 
    'Turn off ScreenUpdating and Events so that users can't see what is 
    'happening and can't affect the code while it is running.
    Application.ScreenUpdating = False
    Application.EnableEvents = False
 
    'Check for no entry.
    If FileName = "" Then End
    
    'Get next available file handle number.
    FileNum = FreeFile()
    
    'Open text file for input.
    Open FileName For Input As #FileNum
    
    'Turn ScreenUpdating off.
    Application.ScreenUpdating = False
 
    'Set the counter to 1.
    Counter = 1
 
    'Place the data in the first row of the column.
    Range("A1").Activate
 
    'Loop until the end of file is reached.
    Do While Seek(FileNum) <= LOF(FileNum)
 
        'Show row number being imported on status bar.
        Application.StatusBar = "Importing Row " & _
                Counter & " of text file " & FileName
 
        'Store one line of text from file to variable.
        Line Input #FileNum, ResultStr
 
        'Initialize the CommaCount variable to zero.
        CommaCount = 0
        
        'Store the entire string into a second, temporary string.
        WorkResult = ResultStr
 
        'Parse through the first line of data and separate out records 
        '257 to 510.
        While CommaCount < 255
 
            WorkResult = Right(WorkResult, Len(WorkResult) - InStr(1, WorkResult, ","))
            CommaCount = CommaCount + 1
 
        Wend
 
        'Parse out any leading spaces.
        If Left(WorkResult, 1) = " " Then WorkResult = Right(WorkResult, Len(WorkResult) - 1)
 
        'Ensure that any records that contain an "=" sign are 
        'brought in as text, and set the value of the current
        'cell to the first 256 records.
        If Left(WorkResult, 1) = "=" Then
            ActiveCell.Value = "'" & Left(ResultStr, Len(ResultStr) - Len(WorkResult))
        Else
            ActiveCell.Value = Left(ResultStr, Len(ResultStr) - Len(WorkResult))
        End If
 
        'Ensure that any records that contain an "=" sign are 
        'brought in as text,and set the value of the next cell 
        'to the last 256 records.
        If Left(WorkResult, 1) = "=" Then
            ActiveCell.Offset(0, 1).Value = "'" & WorkResult
        Else
            ActiveCell.Offset(0, 1).Value = WorkResult
        End If
 
        'Move down one cell.
        ActiveCell.Offset(1, 0).Activate
 
        'Increment the Counter by 1.
        Counter = Counter + 1
 
        'Start again at top of 'Do While' statement.
    Loop
 
    'Close the open text file.
    Close
 
    'Take records 257-510 and move them to sheet two.
    Columns("B:B").Select
    Selection.Cut
    Sheets("Sheet2").Select
    Columns("A:A").Select
    ActiveSheet.Paste
 
    'Run the text-to-columns wizard on both sheets.
    Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
            TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
            Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
            :=Array(Array(1, 1), Array(2, 1), Array(3, 1))
    Sheets("Sheet1").Select
    Columns("A:A").Select
    Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
            TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
            Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
            :=Array(Array(1, 1), Array(2, 1), Array(3, 1))
 
    'Reset the application to its normal operating environment.
    Application.StatusBar = False
    Application.EnableEvents = True
    Application.ScreenUpdating = True
 
    Exit Sub
 
ErrorCheck:
 
    'Reset the application to its normal operating environment.
    Application.StatusBar = False
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    MsgBox "An error occured in the code."
 
End Sub
[+][-]10.09.2008 at 05:54AM PDT, ID: 22677792

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.09.2008 at 06:21AM PDT, ID: 22678059

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.09.2008 at 06:35AM PDT, ID: 22678185

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.09.2008 at 07:58AM PDT, ID: 22679038

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.09.2008 at 08:22AM PDT, ID: 22679324

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.09.2008 at 08:33AM PDT, ID: 22679432

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.09.2008 at 08:42AM PDT, ID: 22679532

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.09.2008 at 08:45AM PDT, ID: 22679562

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.09.2008 at 08:51AM PDT, ID: 22679623

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.09.2008 at 08:56AM PDT, ID: 22679675

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.13.2008 at 03:20PM PDT, ID: 22707072

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.29.2008 at 11:44PM PST, ID: 23062312

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-44 / EE_QW_2_20070628