Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy entire contents of a column 1

Status
Not open for further replies.

wayneryeven

Technical User
May 21, 2004
101
GB
Hey all
relatively simple one though i am unsure as to the best design principle to implement it.

I have set my cursor on a cell in row 1. I want to copy from this cell (e.g Current Cell= G1) to the end (i.e. where the last record of data is in column G. I jsut need to know how to best select the data, the copying etc i can go from there. The data always starts in row 1.

Cheers for your help guys,
wayner1980
 
if your data is contiguous then you could use
lastcell = activecell.end(xldown).address to find the last cell

otherwise lastcell = cells(rows.count,activecell.column).end(xlup).address

with both methods (although i've used activecell in quite a contradictory way!) there is no need for selection.

then range(activecell,lastcell).copy should do the job

;-)
If a man says something and there are no women there to hear him, is he still wrong? [ponder]
How do I get the best answers?
 


Hi,
Code:
with selection
  Range(Cells(1, .Column), Cells(Cells.Rows.Count, .Column).End(xlUp)).Copy
end with


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
hey Skip
Thanks for the reply. This copies Column A-i have my cursor in a column and all (it can change) in row 1. How could i adapt this to copy the column i am in rather than Column A?

Thanks
 


It already does that.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
you'd change
Range(Cells(1, .Column), etc
to
Range(Cells(.row, .Column), etc

;-)
If a man says something and there are no women there to hear him, is he still wrong? [ponder]
How do I get the best answers?
 
Skip- Apologies, my copying and pasting skills have somewhat left me today. Thank you, works a treat my good man.

Loomah- cheers for your input too.

Good work guys.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top