Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Need Help - Copy a Cell

I'm looking for a simpler way of doing the following:

Sub CopyCell()
Sheets("SHEET1").Range("A1").Copy Sheets("SHEET2").Range("A1")
Sheets("SHEET1").Range("A2").Copy Sheets("SHEET2").Range("A1")
Sheets("SHEET1").Range("A3").Copy Sheets("SHEET2").Range("A1")
Sheets("SHEET1").Range("A4").Copy Sheets("SHEET2").Range("A1")
Sheets("SHEET1").Range("A5").Copy Sheets("SHEET2").Range("A1")
End Sub

The data in sheet1, column A is dynamic, it may contain 5 records or 500.
Instead of adding additional lines of code, is there a routine that can be
used that provides the same results?

Thanks,

Donnie


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Need Help - Copy a Cell

Clarification needed. It appears you are trying to copy 5 different cells on
sheet1 all to "A1" of sheet2. This is not usually done. Do you want sheet2
to be a copy of sheet1?
"Donnie Stone" wrote in message
...
I'm looking for a simpler way of doing the following:

Sub CopyCell()
Sheets("SHEET1").Range("A1").Copy Sheets("SHEET2").Range("A1")
Sheets("SHEET1").Range("A2").Copy Sheets("SHEET2").Range("A1")
Sheets("SHEET1").Range("A3").Copy Sheets("SHEET2").Range("A1")
Sheets("SHEET1").Range("A4").Copy Sheets("SHEET2").Range("A1")
Sheets("SHEET1").Range("A5").Copy Sheets("SHEET2").Range("A1")
End Sub

The data in sheet1, column A is dynamic, it may contain 5 records or 500.
Instead of adding additional lines of code, is there a routine that can be
used that provides the same results?

Thanks,

Donnie




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Need Help - Copy a Cell

Mike,

I'm wanting to copy one cell at a time (ascending order) from sheet1, column
A to sheet2, A1. I do not want a copy of sheet1.

Donnie

"Mike Fogleman" wrote in message
...
Clarification needed. It appears you are trying to copy 5 different cells

on
sheet1 all to "A1" of sheet2. This is not usually done. Do you want sheet2
to be a copy of sheet1?
"Donnie Stone" wrote in message
...
I'm looking for a simpler way of doing the following:

Sub CopyCell()
Sheets("SHEET1").Range("A1").Copy Sheets("SHEET2").Range("A1")
Sheets("SHEET1").Range("A2").Copy Sheets("SHEET2").Range("A1")
Sheets("SHEET1").Range("A3").Copy Sheets("SHEET2").Range("A1")
Sheets("SHEET1").Range("A4").Copy Sheets("SHEET2").Range("A1")
Sheets("SHEET1").Range("A5").Copy Sheets("SHEET2").Range("A1")
End Sub

The data in sheet1, column A is dynamic, it may contain 5 records or

500.
Instead of adding additional lines of code, is there a routine that can

be
used that provides the same results?

Thanks,

Donnie






  #4   Report Post  
Posted to microsoft.public.excel.programming
pk pk is offline
external usenet poster
 
Posts: 27
Default Need Help - Copy a Cell

I'm not sure what your criteria are, but the following
will do what you want, acting on any non-blank cell
encountered. Write lines three and four on one row in
your module:

For Each cell In ActiveSheet.UsedRange.Columns(1).Rows
If cell.FormulaR1C1 < "" Then
cell.Copy Destination:=Sheets("Sheet2").Range
("A1")
End If
Next cell

Hope this helps...

-----Original Message-----
I'm looking for a simpler way of doing the following:

Sub CopyCell()
Sheets("SHEET1").Range("A1").Copy Sheets

("SHEET2").Range("A1")
Sheets("SHEET1").Range("A2").Copy Sheets

("SHEET2").Range("A1")
Sheets("SHEET1").Range("A3").Copy Sheets

("SHEET2").Range("A1")
Sheets("SHEET1").Range("A4").Copy Sheets

("SHEET2").Range("A1")
Sheets("SHEET1").Range("A5").Copy Sheets

("SHEET2").Range("A1")
End Sub

The data in sheet1, column A is dynamic, it may contain

5 records or 500.
Instead of adding additional lines of code, is there a

routine that can be
used that provides the same results?

Thanks,

Donnie


.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Need Help - Copy a Cell

PK,

Thanks for the help. It works great!

"pk" wrote in message
...
I'm not sure what your criteria are, but the following
will do what you want, acting on any non-blank cell
encountered. Write lines three and four on one row in
your module:

For Each cell In ActiveSheet.UsedRange.Columns(1).Rows
If cell.FormulaR1C1 < "" Then
cell.Copy Destination:=Sheets("Sheet2").Range
("A1")
End If
Next cell

Hope this helps...

-----Original Message-----
I'm looking for a simpler way of doing the following:

Sub CopyCell()
Sheets("SHEET1").Range("A1").Copy Sheets

("SHEET2").Range("A1")
Sheets("SHEET1").Range("A2").Copy Sheets

("SHEET2").Range("A1")
Sheets("SHEET1").Range("A3").Copy Sheets

("SHEET2").Range("A1")
Sheets("SHEET1").Range("A4").Copy Sheets

("SHEET2").Range("A1")
Sheets("SHEET1").Range("A5").Copy Sheets

("SHEET2").Range("A1")
End Sub

The data in sheet1, column A is dynamic, it may contain

5 records or 500.
Instead of adding additional lines of code, is there a

routine that can be
used that provides the same results?

Thanks,

Donnie


.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Need Help - Copy a Cell

PK,

I have a header in row 1. Is it possible to modify the code so it excludes
it?


"pk" wrote in message
...
I'm not sure what your criteria are, but the following
will do what you want, acting on any non-blank cell
encountered. Write lines three and four on one row in
your module:

For Each cell In ActiveSheet.UsedRange.Columns(1).Rows
If cell.FormulaR1C1 < "" Then
cell.Copy Destination:=Sheets("Sheet2").Range
("A1")
End If
Next cell

Hope this helps...

-----Original Message-----
I'm looking for a simpler way of doing the following:

Sub CopyCell()
Sheets("SHEET1").Range("A1").Copy Sheets

("SHEET2").Range("A1")
Sheets("SHEET1").Range("A2").Copy Sheets

("SHEET2").Range("A1")
Sheets("SHEET1").Range("A3").Copy Sheets

("SHEET2").Range("A1")
Sheets("SHEET1").Range("A4").Copy Sheets

("SHEET2").Range("A1")
Sheets("SHEET1").Range("A5").Copy Sheets

("SHEET2").Range("A1")
End Sub

The data in sheet1, column A is dynamic, it may contain

5 records or 500.
Instead of adding additional lines of code, is there a

routine that can be
used that provides the same results?

Thanks,

Donnie


.



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
Code to copy the formulae of one cell to all the cell in the rangewith the specific cell and columnnumber changing Options Yuvraj Excel Discussion (Misc queries) 0 June 29th 09 11:20 AM
Code to copy the formulae of one cell to all the cell in the rangewith the specific cell and columnnumber changing Yuvraj Excel Discussion (Misc queries) 0 June 26th 09 06:01 PM
How can I copy a value from a cell and paste it into another cell while adding it to the previous value in that cell [email protected] Excel Worksheet Functions 2 November 7th 07 09:39 AM
I copy a formula and the results copy from the original cell brooklynsd Excel Discussion (Misc queries) 1 June 23rd 07 01:35 AM
VBA to copy to empty cell directly below a cell when analogous cells in different column have same value as each other? Steven Rosenberg Excel Programming 0 August 5th 03 06:10 AM


All times are GMT +1. The time now is 12:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"