#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Code issue

I have modified some existing code and for some reason when the paste happens
instead of only pasting to the "D" column, it is pasting to multiple columns
and throwing my data out of format. Can you please tell me what is wrong and
how do I fix it?

ActiveWindow.LargeScroll Down:=1
Range("J23790").Select
ActiveCell.FormulaR1C1 = "1"
Range("J23790").Select
Selection.NumberFormat = "0"
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone

Range("J23790").Select
Selection.Copy
Range("D2:D23501").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
With Selection.Font
.Name = "Tahoma"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With


Thank you,

Fred
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Code issue

Hi,

I tidied you recorded code up a bit and it should now do what you want

Sub Sonic()
With Range("J23790")
.Value = 1
.NumberFormat = "0"
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Copy
End With

With Range("D2:D23501")
.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, _
SkipBlanks:=False, Transpose:=False
End With

With Range("D2:D23501").Font
.Name = "Tahoma"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With

End Sub


Mike

"fgwiii" wrote:

I have modified some existing code and for some reason when the paste happens
instead of only pasting to the "D" column, it is pasting to multiple columns
and throwing my data out of format. Can you please tell me what is wrong and
how do I fix it?

ActiveWindow.LargeScroll Down:=1
Range("J23790").Select
ActiveCell.FormulaR1C1 = "1"
Range("J23790").Select
Selection.NumberFormat = "0"
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone

Range("J23790").Select
Selection.Copy
Range("D2:D23501").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
With Selection.Font
.Name = "Tahoma"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With


Thank you,

Fred

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Code issue


Hello,

I placed the code in and it still appears to do the same thing. the format
is pasted Columns C through G with the format of "0".

I stepped through it and when it gets to :
With Range("D2:D23501")
..PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply,

the format gets pasted.

Just in case something else is hosing this, here is the rest of the code
prior to the code you corrected:

ActiveWindow.LargeScroll Down:=40
Range("J23790").Select
ActiveCell.FormulaR1C1 = "1"
Range("J23790").Select
Selection.NumberFormat = "0"
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Range("J23790")
..Value = 1
..NumberFormat = "0"
..Borders(xlDiagonalDown).LineStyle = xlNone
..Borders(xlDiagonalUp).LineStyle = xlNone
..Copy
End With

With Range("D2:D23501")
..PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, _
SkipBlanks:=False, Transpose:=False
End With

With Range("D2:D23501").Font
..Name = "Tahoma"
..Size = 12
..Strikethrough = False
..Superscript = False
..Subscript = False
..OutlineFont = False
..Shadow = False
..Underline = xlUnderlineStyleNone
..ColorIndex = xlAutomatic
End With

Thanks



"Mike H" wrote:

Hi,

I tidied you recorded code up a bit and it should now do what you want

Sub Sonic()
With Range("J23790")
.Value = 1
.NumberFormat = "0"
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Copy
End With

With Range("D2:D23501")
.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, _
SkipBlanks:=False, Transpose:=False
End With

With Range("D2:D23501").Font
.Name = "Tahoma"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With

End Sub


Mike

"fgwiii" wrote:

I have modified some existing code and for some reason when the paste happens
instead of only pasting to the "D" column, it is pasting to multiple columns
and throwing my data out of format. Can you please tell me what is wrong and
how do I fix it?

ActiveWindow.LargeScroll Down:=1
Range("J23790").Select
ActiveCell.FormulaR1C1 = "1"
Range("J23790").Select
Selection.NumberFormat = "0"
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone

Range("J23790").Select
Selection.Copy
Range("D2:D23501").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
With Selection.Font
.Name = "Tahoma"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With


Thank you,

Fred

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
Macro Code Issue uncbluegal Excel Programming 2 June 5th 09 06:03 PM
Need assistance with code issue?? Mekinnik Excel Programming 1 December 13th 07 07:25 PM
Code issue Tom Excel Programming 4 May 29th 07 10:31 AM
Autofit code Issue Joe Excel Programming 0 December 20th 05 04:12 PM
VBA Code issue scrabtree23[_3_] Excel Programming 2 December 4th 04 04:26 PM


All times are GMT +1. The time now is 10:54 PM.

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

About Us

"It's about Microsoft Excel"