Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / General Excel Questions / March 2008

Tip: Looking for answers? Try searching our database.

VBA Code- Copy & Paste in Blank Range

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Youlan - 19 Mar 2008 23:08 GMT
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.
Don Guillett - 20 Mar 2008 00:09 GMT
sub copytonextcol()
mr=5    'row
lastcol=cells(mr,columns.count).end(xltoleft).column+1
Range("D5:D93").copy
cells(mr,lastcol).PasteSpecial Paste:=xlPasteValues
end sub
Signature

Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett1@austin.rr.com

> Hi,
>
[quoted text clipped - 27 lines]
>
> I would greatly appreciate any help with this. Thanks in advance.
Youlan - 20 Mar 2008 21:44 GMT
> sub copytonextcol()
> mr=5    'row
[quoted text clipped - 33 lines]
> >
> > I would greatly appreciate any help with this. Thanks in advance.
Don Guillett - 20 Mar 2008 22:45 GMT
Youlan wrote
_______________?

Signature

Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett1@austin.rr.com

>
>> sub copytonextcol()
[quoted text clipped - 36 lines]
>> >
>> > I would greatly appreciate any help with this. Thanks in advance.
Youlan - 20 Mar 2008 23:30 GMT
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?

> Youlan wrote
> _______________?
[quoted text clipped - 38 lines]
> >> >
> >> > I would greatly appreciate any help with this. Thanks in advance.
Don Guillett - 20 Mar 2008 23:41 GMT
Did you copy all lines?

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

Signature

Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett1@austin.rr.com

> Hi Don,
>
[quoted text clipped - 51 lines]
>> >> >
>> >> > I would greatly appreciate any help with this. Thanks in advance.
Youlan - 21 Mar 2008 00:07 GMT
Thanks Don,

It works but not with a commandbutton ( I was doing it with a command button
before maybe thats why it wasn't working before)

Also I wanted it to start pasting in the next blank column (starting at row
5) not the last column and not the entire column. Also this process is to be
repeated everytime the macro is evoked. Can this be done?

I hope I'm not giving you too much trouble. Thanks again.

> Did you copy all lines?
>
[quoted text clipped - 62 lines]
> >> >> >
> >> >> > I would greatly appreciate any help with this. Thanks in advance.
Don Guillett - 21 Mar 2008 00:50 GMT
So I don't have to re-create, send a workbook along with what you want. Most
never use command buttons. I usually asign to a shape. Did one for a client
the other day assigned to his logo.

Signature

Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett1@austin.rr.com

> Thanks Don,
>
[quoted text clipped - 80 lines]
>> >> >> >
>> >> >> > I would greatly appreciate any help with this. Thanks in advance.
Youlan - 25 Mar 2008 18:00 GMT
Hi Don,

Yeah, I realize command buttons can be a little finicky. I'll just use a
graphic.

I'm going to send the workbook to the e-mail address. I've typed what I want
to do in the comments in D4.

Thanks again

> So I don't have to re-create, send a workbook along with what you want. Most
> never use command buttons. I usually asign to a shape. Did one for a client
[quoted text clipped - 84 lines]
> >> >> >> >
> >> >> >> > I would greatly appreciate any help with this. Thanks in advance.
Don Guillett - 27 Mar 2008 16:22 GMT
Sent him this.

Sub CopyToNextAvailCol()
mr = 5
mc = "d"
lc = Cells(mr, mc).End(xlToRight).Column + 1
Range(Cells(mr, "f"), Cells(93, "f")).Value = _
Range(Cells(mr, lc - 1), Cells(93, lc - 1)).Value
Range(Cells(mr, lc), Cells(93, lc)).Value = _
Range(Cells(mr, mc), Cells(93, mc)).Value
End Sub

Signature

Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett1@austin.rr.com

> Hi Don,
>
[quoted text clipped - 101 lines]
>> >> >> >> > I would greatly appreciate any help with this. Thanks in
>> >> >> >> > advance.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.