View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default VBA Code- Copy & Paste in Blank Range

Did you copy all lines?

sub copytonextcol()
mr=5 'row
lastcol=cells(mr,columns.count).end(xltoleft).colu mn+1
Range("D5:D93").copy
cells(mr,lastcol).PasteSpecial Paste:=xlPasteValues
'line below added
Application.CutCopyMode = False
end sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Youlan" wrote in message
...
Hi Don,

I don't know why you wern't able to see what I wrote before.

Thanks for your help but I am still having a little problem because when I
run the macro I get the following compile error:

"Expected End Sub"

Can you help please?

"Don Guillett" wrote:

Youlan wrote
_______________?

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Youlan" wrote in message
...


"Don Guillett" wrote:

sub copytonextcol()
mr=5 'row
lastcol=cells(mr,columns.count).end(xltoleft).colu mn+1
Range("D5:D93").copy
cells(mr,lastcol).PasteSpecial Paste:=xlPasteValues
end sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Youlan" wrote in message
...
Hi,

I'm using Excel 2002

I'm trying to write a code to copy and paste special a range of data
in
the
next empty cell. Therefore if cell j5 has data it would start
pasting
it
in
only k5 and so on. This is what I have so far but its pasting in all
the
columns where row 5 is blank:

If Range("j5").Value = " " Then

End If

ActiveWindow.SmallScroll ToRight:=-1
Range("D5:D93").Select
Selection.copy
ActiveWindow.SmallScroll Down:=-123
ActiveWindow.SmallScroll ToRight:=15
ActiveWindow.SmallScroll Down:=-15
Range("j5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

End If

Else

I would greatly appreciate any help with this. Thanks in advance.