Macro to copy cells

jaimed77089

New Member
Joined
Nov 3, 2005
Messages
10
I have a spreadsheet where I need to copy three cells in a row down a column, however the number of cells I need to copy down the column varies, according to the number of rows I have on another sheet, is there a way to run the macro to count the rows on my source sheet, and copy the cells from the other sheet down only that number of rows?
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
I'm sure it can be done. Post your worksheets and explain exactly what determines the number of cells, where the copy starts and where the paste needs to go.
 
Upvote 0
I can't figure out how to attach....I promise I'm not computer illiterate...What I want to do is copy the three cells G6, H6, and I6 into C, D and E, all the way down for same number of rows as I have input into the Source sheet. It should copy down 32 rows in my example. If I hid cells, I don't want those to count.
[/img]
 
Upvote 0
I can't install software on my computer...let me try to describe it a little better:

Source Sheet Sheet 2

a Column1 C2 C3 Copy1 C2 C3
b
c
d
e
f
g
h

I want to copy the three cells on sheet 2 into Columns 1, 2, and 3 down as many rows as can be found on the source sheet, so in this case, I would copy down 8 rows, BUT the number of rows in the source sheet can change, and they include hidden rows, so I want something that will count how many visible rows, and only copy the cells down for that number.
 
Upvote 0
How about this:
Sub macro()
Dim cell As Range
Range("A1:A" & [a65536].End(xlUp).Row).Select
For Each cell In Selection
If cell.RowHeight > 0 Then Range(cell, cell.Offset(0, 2)).Copy Destination:=Sheets("Sheet3").[a65536].End(xlUp).Offset(1, 0)
Next cell
End Sub
 
Upvote 0
Or :-

Code:
Sub macro() 
Range("A1:A" & [a65536].End(xlUp).Row).SpecialCells(xlCellTypeVisible).Copy _
    Sheets("Sheet3").[a65536].End(xlUp).Offset(1, 0)
End Sub
 
Upvote 0
This is what I currently have in there, but basically I am copying down 1000 rows, b/c that is usually about how many i have in my source document. The source document is called "Master" and the other documents are something like "Assign 5-17"...So how would your code fit into this?

Range("K10:N10").Select
Application.CutCopyMode = False
Selection.Copy
Range("D10:D1000").Select
ActiveSheet.Paste
Application.CutCopyMode = False
 
Upvote 0

Forum statistics

Threads
1,224,879
Messages
6,181,531
Members
453,054
Latest member
ezzat

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top