PC Review


Reply
Thread Tools Rate Thread

Ctrl+Shift+Down in a macro - doesn't re-run

 
 
Astello
Guest
Posts: n/a
 
      16th Oct 2006
I'm using a macro to basically add new columns to data pulled from
Access. I pulled 4 extra columns that I can re-write to be the same
length as the data I actually need. So in my macro, I recorded
Ctrl+Shift+Down to paste the data the length of the column, but this
function does not get translated when I pull data that is longer than
the original data I wrote the macro on. Is there a way to re-write
this so that it goes to the end of the column each time it is executed,
no matter how long the column is?

Here is the code I have:

Range("P2").Select
Selection.Copy
Range("P3").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
ActiveWindow.SmallScroll Down:=-3

 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q2hhcmxlcyBDaGlja2VyaW5n?=
Guest
Posts: n/a
 
      16th Oct 2006
The code you have should work just fine. However there is a shorter way to do
it.
Range("P2").Copy
Range("P3",Range("P3").End(xlDown)).PasteSpecial xlPasteAll

The Ctrl+Down thing is basically the "End(xlDown)" part.
--
Charles Chickering

"A good example is twice the value of good advice."


"Astello" wrote:

> I'm using a macro to basically add new columns to data pulled from
> Access. I pulled 4 extra columns that I can re-write to be the same
> length as the data I actually need. So in my macro, I recorded
> Ctrl+Shift+Down to paste the data the length of the column, but this
> function does not get translated when I pull data that is longer than
> the original data I wrote the macro on. Is there a way to re-write
> this so that it goes to the end of the column each time it is executed,
> no matter how long the column is?
>
> Here is the code I have:
>
> Range("P2").Select
> Selection.Copy
> Range("P3").Select
> Range(Selection, Selection.End(xlDown)).Select
> ActiveSheet.Paste
> ActiveWindow.SmallScroll Down:=-3
>
>

 
Reply With Quote
 
Astello
Guest
Posts: n/a
 
      16th Oct 2006
I just realized that there were some empty cells, so the
ctrl+shift+down only selected up to the empty cell and didn't paste the
cells below it. i'll have to write a function to get rid of rows with
empty cells, or fill empty cells with a placeholder.

Charles Chickering wrote:
> The code you have should work just fine. However there is a shorter way to do
> it.
> Range("P2").Copy
> Range("P3",Range("P3").End(xlDown)).PasteSpecial xlPasteAll
>
> The Ctrl+Down thing is basically the "End(xlDown)" part.
> --
> Charles Chickering
>
> "A good example is twice the value of good advice."
>
>
> "Astello" wrote:
>
> > I'm using a macro to basically add new columns to data pulled from
> > Access. I pulled 4 extra columns that I can re-write to be the same
> > length as the data I actually need. So in my macro, I recorded
> > Ctrl+Shift+Down to paste the data the length of the column, but this
> > function does not get translated when I pull data that is longer than
> > the original data I wrote the macro on. Is there a way to re-write
> > this so that it goes to the end of the column each time it is executed,
> > no matter how long the column is?
> >
> > Here is the code I have:
> >
> > Range("P2").Select
> > Selection.Copy
> > Range("P3").Select
> > Range(Selection, Selection.End(xlDown)).Select
> > ActiveSheet.Paste
> > ActiveWindow.SmallScroll Down:=-3
> >
> >


 
Reply With Quote
 
=?Utf-8?B?Q2hhcmxlcyBDaGlja2VyaW5n?=
Guest
Posts: n/a
 
      16th Oct 2006
Or better yet work from the bottom up...
Range("P2").Copy
Range("P3",Range("P" & Rows.Count).End(xlUp)).PasteSpecial xlPasteAll

--
Charles Chickering

"A good example is twice the value of good advice."


"Astello" wrote:

> I just realized that there were some empty cells, so the
> ctrl+shift+down only selected up to the empty cell and didn't paste the
> cells below it. i'll have to write a function to get rid of rows with
> empty cells, or fill empty cells with a placeholder.
>
> Charles Chickering wrote:
> > The code you have should work just fine. However there is a shorter way to do
> > it.
> > Range("P2").Copy
> > Range("P3",Range("P3").End(xlDown)).PasteSpecial xlPasteAll
> >
> > The Ctrl+Down thing is basically the "End(xlDown)" part.
> > --
> > Charles Chickering
> >
> > "A good example is twice the value of good advice."
> >
> >
> > "Astello" wrote:
> >
> > > I'm using a macro to basically add new columns to data pulled from
> > > Access. I pulled 4 extra columns that I can re-write to be the same
> > > length as the data I actually need. So in my macro, I recorded
> > > Ctrl+Shift+Down to paste the data the length of the column, but this
> > > function does not get translated when I pull data that is longer than
> > > the original data I wrote the macro on. Is there a way to re-write
> > > this so that it goes to the end of the column each time it is executed,
> > > no matter how long the column is?
> > >
> > > Here is the code I have:
> > >
> > > Range("P2").Select
> > > Selection.Copy
> > > Range("P3").Select
> > > Range(Selection, Selection.End(xlDown)).Select
> > > ActiveSheet.Paste
> > > ActiveWindow.SmallScroll Down:=-3
> > >
> > >

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ctrl-Shift-Space Doesn't Work Any More Idaho Word Man Microsoft Word Document Management 4 3rd May 2011 07:27 PM
Re: Macro's with Ctrl or Ctrl-Shift? Al Franz Microsoft Excel Discussion 2 5th Sep 2005 10:48 PM
Re: Macro's with Ctrl or Ctrl-Shift? Al Franz Microsoft Excel Discussion 1 5th Sep 2005 09:58 PM
CTRL+Shift+Arrow Doesn't Work =?Utf-8?B?RWxvbg==?= Microsoft Excel Misc 2 26th May 2005 01:12 PM
Shift-Ctrl-<Arrow> doesn't work bats Microsoft Excel Discussion 3 28th Aug 2004 05:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:55 AM.