Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 151
Default Forcing xl2K7 Column Count back to xl2K3 size

Hi all

My company has upgraded most of its systems to run 2007 which has
created an issue for me as one of my files does not like working with it
which I'm fairly certain relates to the sheets column count.

I download a CSV file from another company that has to be converted
before I can essentially upload it into my workbook so all the "Do
Something Stuff"has to be done prior., As I now run 2007 the CSV opens
within that version environment and it is here where things go to crap.

When it comes time to copying and pasting the entire row ( A to XFD
)across to my 2003 structured worksheet which is only ( AA to IV ), it
throws a hissy-fit and halts because they are different sizes.

If copyLine = True Then
Rows(i & ":" & i).Select
Selection.Cut
Windows(cWkBook).Activate
Sheets("TMS DATA").Select
Rows(lastrow).Select
ActiveSheet.Paste <<<




This is the code that actually opens the CSV file, is there a line I can
insert at the beginning that would tell the 2007 workbook being opened
to reduce it's column count back to ( A to IV ) before it starts doing
it's thing..

Sub openCSV(inp As String)
On Error Resume Next

Workbooks.OpenText Filename:=inp, _
Origin:=xlMSDOS, StartRow:=1, DataType:=xlDelimited,
TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False,
Semicolon:=False _
, Comma:=True, Space:=False, Other:=False,
FieldInfo:=Array(Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6,
1), Array(7, 1), Array(8, 1), _
Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1),
Array(13, 1), Array(14, 1), Array(15 _
, 1), Array(16, 1)), TrailingMinusNumbers:=True

Columns("F:F").Select
Selection.Delete Shift:=xlToLeft

Columns("N:N").Select
Selection.Insert Shift:=xlToRight

For x = 1 To 10000

tVal = Cells(x, 12).Value
tVal1 = Cells(x, 13).Value
tVal3 = tVal & tVal1

If tVal3 = "" Then
Exit For
End If

tTime = WorksheetFunction.Search(" ", tVal)
If tTime < "" Then
tTime = Right(tVal, Len(tVal) - tTime)
End If

tTime1 = WorksheetFunction.Search(" ", tVal1)
If tTime1 < "" Then
tTime1 = Right(tVal1, Len(tVal1) - tTime1)
End If

If IsDate(tVal) Then
Cells(x, 12).Value = Day(Cells(x, 12).Value) & "/" & Month(Cells(x,
12).Value) & "/" & Year(Cells(x, 12).Value) '& " " & tTime

End If

If IsDate(tVal1) Then
Cells(x, 13).Value = Day(Cells(x, 13).Value) & "/" & Month(Cells(x,
13).Value) & "/" & Year(Cells(x, 13).Value) '& " " & tTime1
End If

tVal = ""
tVal1 = ""
tTime = ""
tTime1 = ""
Next x

Columns("M:M").Select
Selection.NumberFormat = "dd/mm/yyyy"

End Sub

I really appreciate any assistance please..

TIA
Mick.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Forcing xl2K7 Column Count back to xl2K3 size

Mick,

Have you tried changing this line from:

If copyLine = True Then
Rows(i & ":" & i).Select
Selection.Cut

to:

If copyLine = True Then
Range("A" & i & ":" & "IV" & i).Cut

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default Forcing xl2K7 Column Count back to xl2K3 size

If copyLine = True Then
Intersect(ActiveSheet.usedRange, Rows(i & ":" & i)).Select
Selection.Cut


That function "Intersect(ActiveSheet.usedRange, ...)" is really useful. Mostly I use it as a performance improvement if I'm looping over all cells or rows or columns in a range.

Phil.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 151
Default Forcing xl2K7 Column Count back to xl2K3 size

Hi all

Well it seems I took the long-winded scenic route on this one.

I managed a workaround for it, so instead of this:

If copyLine = True Then
Rows(i & ":" & i).Select
Selection.Cut

I changed it to this:

If copyLine = True Then
Range(Cells(i, 1),Cells(i, 256)).Select
Selection.Cut

And it work well..

Cheers
Mick.
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
Forcing a certain date format in an Excel column angela Excel Programming 1 January 26th 07 02:46 AM
Changed column width keeps reverting back to original size David Boone Excel Discussion (Misc queries) 3 May 29th 05 01:22 PM
Formula bar height in XL2K3 w/XP Jon Bouy Excel Discussion (Misc queries) 8 February 24th 05 02:09 AM
Can we write VBA code to set all column/row's size back to default size? Charles Williams Excel Programming 0 July 8th 03 03:56 PM
Can we write VBA code to set all column/row's size back to default size? Earle Excel Programming 0 July 8th 03 02:46 PM


All times are GMT +1. The time now is 02:56 AM.

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"