Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Selecting data to copy and paste

I have a macro that sorts data into the correct order, then I manually copy
and paste into a different application. I would like to write code into the
macro that copies the data after sorting, but the length of the data list is
variable, i.e. sometimes it could be spread from A1 to A52, sometimes A1 to
A105. Each time can give a different length, (but always in column A only).
Also, some of the cells are blank, but must be copied as blank.
Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Selecting data to copy and paste

Hi Black country boy,

To define your variable column A range try something like:

'================
Public Sub Tester001()
Dim WB As Workbook
Dim SH As Worksheet
Dim rng As Range

Set WB = Workbooks("Book1") '<<==== CHANGE
Set SH = WB.Sheets("Sheet11") '<<==== CHANGE

iLastRow = SH.Cells(Rows.Count, "A").End(xlUp).Row

Set rng = SH.Range("A1:A" & iLastRow)

'Your code

End Sub
'<<================


---
Regards,
Norman


"Black country boy" wrote in
message ...
I have a macro that sorts data into the correct order, then I manually copy
and paste into a different application. I would like to write code into
the
macro that copies the data after sorting, but the length of the data list
is
variable, i.e. sometimes it could be spread from A1 to A52, sometimes A1
to
A105. Each time can give a different length, (but always in column A
only).
Also, some of the cells are blank, but must be copied as blank.
Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Selecting data to copy and paste

Hi Black country boy,

If your workbook has previously been saved, change:

Set WB = Workbooks("Book1") '<<==== CHANGE


to

Set WB = Workbooks("Book1.xls") '<<==== CHANGE



---
Regards,
Norman


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Selecting data to copy and paste

On Apr 16, 5:10 pm, Black country boy
wrote:
I have a macro that sorts data into the correct order, then I manually copy
and paste into a different application. I would like to write code into the
macro that copies the data after sorting, but the length of the data list is
variable, i.e. sometimes it could be spread from A1 to A52, sometimes A1 to
A105. Each time can give a different length, (but always in column A only).
Also, some of the cells are blank, but must be copied as blank.
Thanks.


Hi, Black Country Boy:

Would you please give me an example telling me what you need? I am not
sure whether I can solve your problem.

Thanks,


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Selecting data to copy and paste

Thanks Norman. I will try this at work tomorrow and let you know how I got on.

"Norman Jones" wrote:

Hi Black country boy,

To define your variable column A range try something like:

'================
Public Sub Tester001()
Dim WB As Workbook
Dim SH As Worksheet
Dim rng As Range

Set WB = Workbooks("Book1") '<<==== CHANGE
Set SH = WB.Sheets("Sheet11") '<<==== CHANGE

iLastRow = SH.Cells(Rows.Count, "A").End(xlUp).Row

Set rng = SH.Range("A1:A" & iLastRow)

'Your code

End Sub
'<<================


---
Regards,
Norman


"Black country boy" wrote in
message ...
I have a macro that sorts data into the correct order, then I manually copy
and paste into a different application. I would like to write code into
the
macro that copies the data after sorting, but the length of the data list
is
variable, i.e. sometimes it could be spread from A1 to A52, sometimes A1
to
A105. Each time can give a different length, (but always in column A
only).
Also, some of the cells are blank, but must be copied as blank.
Thanks.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Selecting data to copy and paste

Norman
I did as you instructed, but the macro would not start. I found the
following in Excel help:
ActiveSheet.UsedRange.Copy
This was sufficent because only column 1 has data in, and it was the whole
of column 1 I needed to copy.
Thanks for your help.
BCB


"Norman Jones" wrote:

Hi Black country boy,

If your workbook has previously been saved, change:

Set WB = Workbooks("Book1") '<<==== CHANGE


to

Set WB = Workbooks("Book1.xls") '<<==== CHANGE



---
Regards,
Norman



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Selecting data to copy and paste

George
Thanks for the interest, but I managed to help myself with:
ActiveSheet.UsedRange.Copy
from Excel help.
Thanks
BCB

"George" wrote:

On Apr 16, 5:10 pm, Black country boy
wrote:
I have a macro that sorts data into the correct order, then I manually copy
and paste into a different application. I would like to write code into the
macro that copies the data after sorting, but the length of the data list is
variable, i.e. sometimes it could be spread from A1 to A52, sometimes A1 to
A105. Each time can give a different length, (but always in column A only).
Also, some of the cells are blank, but must be copied as blank.
Thanks.


Hi, Black Country Boy:

Would you please give me an example telling me what you need? I am not
sure whether I can solve your problem.

Thanks,



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: Selecting "Cancel" from a drop down to copy and paste entirerow to another sheet Nicole Hannington Excel Discussion (Misc queries) 1 July 20th 09 07:11 PM
MACRO: Selecting "Cancel" from a drop down to copy and paste entirerow to another sheet Nicole Hannington Excel Worksheet Functions 1 July 20th 09 06:51 PM
Auto copy/ paste on relevant work sheet when selecting list item Niraj Manglam Excel Programming 1 June 6th 06 03:13 PM
Excel cut/Paste Problem: Year changes after data is copy and paste Asif Excel Discussion (Misc queries) 2 December 9th 05 05:16 PM
Selecting data from 1 workbook to copy and paste to a 2nd workbook JackSpam Excel Programming 2 July 20th 05 02:33 AM


All times are GMT +1. The time now is 08:28 AM.

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"