Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Can't paste today

Done many copy/pastes before, but today, XL doesn't like it!
Sub AllocbyCty()
Dim wbCty As Workbook
Dim sNew As String
Dim lCurCol As Long
Dim wsSource As Worksheet
Dim wsTranspose As Worksheet
Dim sCty As String
Dim lStrDif As Long

Set wsSource = ActiveSheet

lCurCol = 2

wsSource.Range("A1").Select

Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select

Selection.Copy
Sheets.Add.Activate
Set wsTranspose = ActiveSheet
wsTranspose.Name = "Transpose"

Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True

Do Until wsTranspose.Cells(1, lCurCol) = ""

sCty = wsTranspose.Cells(1, lCurCol)
lStrDif = Len(sCty) - 5
sCty = Right(sCty, Len(sCty) - lStrDif)
Range("A1:A4").Select
Selection.Copy
Workbooks.Add.Activate
Set wbCty = ActiveWorkbook
wbCty.SaveAs Filename:=ThisWorkbook.Path & "\" & sCty
Sheets("Sheet1").Range("A1").PasteSpecial Paste:=xlValues,
Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Any suggestions?
Thanks
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Can't paste today

It appears to me that you're trying to transpose 65526 rows x 256 columns (in
Excel 2003) to 65526 Columns x 256 Rows and it won't do that. Put in a
bunch of debug.print statements to figure out where it's going haywire. I'm
guessing it's in the lines with XLToRight and XLDown.
--
HTH,
Barb Reinhardt



"salgud" wrote:

Done many copy/pastes before, but today, XL doesn't like it!
Sub AllocbyCty()
Dim wbCty As Workbook
Dim sNew As String
Dim lCurCol As Long
Dim wsSource As Worksheet
Dim wsTranspose As Worksheet
Dim sCty As String
Dim lStrDif As Long

Set wsSource = ActiveSheet

lCurCol = 2

wsSource.Range("A1").Select

Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select

Selection.Copy
Sheets.Add.Activate
Set wsTranspose = ActiveSheet
wsTranspose.Name = "Transpose"

Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True

Do Until wsTranspose.Cells(1, lCurCol) = ""

sCty = wsTranspose.Cells(1, lCurCol)
lStrDif = Len(sCty) - 5
sCty = Right(sCty, Len(sCty) - lStrDif)
Range("A1:A4").Select
Selection.Copy
Workbooks.Add.Activate
Set wbCty = ActiveWorkbook
wbCty.SaveAs Filename:=ThisWorkbook.Path & "\" & sCty
Sheets("Sheet1").Range("A1").PasteSpecial Paste:=xlValues,
Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Any suggestions?
Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Can't paste today

On Wed, 23 Apr 2008 11:50:01 -0700, Barb Reinhardt wrote:

It appears to me that you're trying to transpose 65526 rows x 256 columns (in
Excel 2003) to 65526 Columns x 256 Rows and it won't do that. Put in a
bunch of debug.print statements to figure out where it's going haywire. I'm
guessing it's in the lines with XLToRight and XLDown.


Thanks for your reply. I should have been clearer. It's not the paste after
the "transpose" that's giving me the problems, it's the one further down
where I'm pasting from cells A1 to A4 into the new workbook.
Sorry about my ignorance, but I don't know what a "debug.print" statement
is or how to use it. What is it? What does it do? How would I use it here?
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Can't paste today

If you put

Debug.Print Selection.Address

In your code, it will print the Selection.Address in the Immediate window.
You can access the Immediate window with CTRL G. You can also step through
your code line by line with F8 or put a breakpoint in with F9 and run to the
breakpoint. It helps with debugging the code.
--
HTH,
Barb Reinhardt



"salgud" wrote:

On Wed, 23 Apr 2008 11:50:01 -0700, Barb Reinhardt wrote:

It appears to me that you're trying to transpose 65526 rows x 256 columns (in
Excel 2003) to 65526 Columns x 256 Rows and it won't do that. Put in a
bunch of debug.print statements to figure out where it's going haywire. I'm
guessing it's in the lines with XLToRight and XLDown.


Thanks for your reply. I should have been clearer. It's not the paste after
the "transpose" that's giving me the problems, it's the one further down
where I'm pasting from cells A1 to A4 into the new workbook.
Sorry about my ignorance, but I don't know what a "debug.print" statement
is or how to use it. What is it? What does it do? How would I use it here?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Can't paste today

On Wed, 23 Apr 2008 15:46:03 -0700, Barb Reinhardt wrote:

If you put

Debug.Print Selection.Address

In your code, it will print the Selection.Address in the Immediate window.
You can access the Immediate window with CTRL G. You can also step through
your code line by line with F8 or put a breakpoint in with F9 and run to the
breakpoint. It helps with debugging the code.


Thanks for your reply. I've figured out the step thru and the breakpoint,
there are icons for those so they're pretty obvious. But debug.print isn't
so obvious. But I checked it out, and I've just been using MsgBox to do the
same thing. I've never figured out what, if anything, the Immediate Window
does. I've tested code in it a few times, but rarely does it work, or give
me any useful information. Now I know it displays the result of a
"debug.print". What else can I "debug.print" besides the selection address?
Are there useful things that debug.print can show? Anything that I can't do
with a MsgBox?
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Can't paste today

You can use Debug.print for just about anything you'd put in a MsgBox for
debugging your code. Debug.print is a whole lot easier to remove when you're
done. I often use MsgBox for other functionality (besides debugging), so I
wouldn't want to remove all MsgBox's
--
HTH,
Barb Reinhardt



"salgud" wrote:

On Wed, 23 Apr 2008 15:46:03 -0700, Barb Reinhardt wrote:

If you put

Debug.Print Selection.Address

In your code, it will print the Selection.Address in the Immediate window.
You can access the Immediate window with CTRL G. You can also step through
your code line by line with F8 or put a breakpoint in with F9 and run to the
breakpoint. It helps with debugging the code.


Thanks for your reply. I've figured out the step thru and the breakpoint,
there are icons for those so they're pretty obvious. But debug.print isn't
so obvious. But I checked it out, and I've just been using MsgBox to do the
same thing. I've never figured out what, if anything, the Immediate Window
does. I've tested code in it a few times, but rarely does it work, or give
me any useful information. Now I know it displays the result of a
"debug.print". What else can I "debug.print" besides the selection address?
Are there useful things that debug.print can show? Anything that I can't do
with a MsgBox?

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
today stew Excel Discussion (Misc queries) 4 September 19th 08 06:15 PM
Keep 6 months of dates from Today to (Today + 6 Months) Joe K. Excel Programming 1 October 9th 07 07:02 PM
IF TODAY equals date in cell A10, or if TODAY is beyond that date SoupNazi Excel Worksheet Functions 4 April 23rd 07 01:14 AM
=IF(OR(TODAY()G9),"Pass","Overdue") Why doe it not wo. Fkor Excel Discussion (Misc queries) 3 March 10th 05 08:29 AM
=TODAY() Craig Petersen via OfficeKB.com Excel Discussion (Misc queries) 3 December 30th 04 05:41 PM


All times are GMT +1. The time now is 06:09 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"