LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Transpose out of range error

Apologies for harping on this! I was supposed to have things finished
by a meeting this morning and I'm still trying to get my head wrapped
around VBA.

I can now open text files as semicolon delimited but I cannot get to
another workbook to paste/append the transposed data. There is an out
of range error at "Set dataBk = Workbooks("data.xls")" but I can see
the file and it does have worksheets.

Feels like I'm close, but maybe I'm really moving in the wrong
direction. Wondering if I've caused a problem by my unskilled use of an
array. Here is the script:

Sub OpenMultipleUserSelectedFiles()
Dim rng1 As Range
Dim rng2 As Range
Dim tempBk As Workbook
Dim dataBk As Workbook
Dim filearray As Variant

filearray = Application.GetOpenFilename _
("Text Files (*.*),*.*,PRN Files (*.prn),*.prn", , , , True)
If IsArray(filearray) Then
For i = LBound(filearray) To UBound(filearray)
Workbooks.OpenText filearray(i), _
Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited,
TextQualifier _
:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, Semicolon:= _
True, Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(1, 1)

Set tempBk = ActiveWorkbook
With tempBk.Worksheets(1)
Set rng1 = .Range(.Cells(1, 1), .Cells(Rows.Count, 1).End(xlUp))
End With

Set dataBk = Workbooks("data.xls")
With dataBk.Worksheets(1)
Set rng2 = .Range(.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0))
End With

rng1.Copy
rng2.PasteSpecial xlValues, Transpose:=True
bk.Close Savechanges:=False
Next i
Else:
MsgBox "You clicked cancel"
End If
End Sub

Any help much appreciated! Trish

 
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
copy transpose and paste error!? Darius Excel Worksheet Functions 3 August 1st 09 04:23 PM
MS Excel transpose error Andy Alegria Excel Discussion (Misc queries) 0 August 28th 08 08:07 PM
Transpose Error escapeman Excel Discussion (Misc queries) 2 December 8th 07 01:39 PM
Transpose Range weeper Excel Programming 2 September 29th 04 08:13 PM
Transpose dynamic range Michael Beckinsale Excel Programming 3 March 5th 04 04:03 PM


All times are GMT +1. The time now is 12:32 PM.

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

About Us

"It's about Microsoft Excel"