copy cell only with contains

R

ramzi

hi,
how to create macro for me to copy only cell with contains.
let say range from a1 to c8.
1st copy let say a1 to c4 only have cotains value and for next copy the
value at
a1 to c6.
the contains of cell keep on changing but within a1 to c8.

how to do this,...
thanks in advance....
 
G

Gary''s Student

This will copy only the non-blanks cells from Sheet1 to Sheet2:

Sub CopyStuff()
Dim s1 As Worksheet
Dim s2 As Worksheet
Set s1 = Sheets("Sheet1")
Set s2 = Sheets("Sheet2")
For Each r In s1.Range("A1:C8")
If r.Value = "" Then
Else
r.Copy s2.Range(r.Address)
End If
Next
End Sub
 
B

Bernard Liengme

It might help if you gave example of the data and what determines if it is
to be copied, and where it is to be copied
best wishes
 
R

ramzi

HI, my macro as below......

In sheet2 I want the 2nd paste data will store next after my 1st paste data...
can u help me on this...


Sub CopyStuff()
Dim s1 As Worksheet
Dim s2 As Worksheet
Set s1 = Sheets("Sheet1")
Set s2 = Sheets("Sheet2")
For Each r In s1.Range("A1:C8")
If r.Value = "" Then
Else
r.Copy s2.Range(r.Address)
lastrow = Sheets("Sheet2").Cells(Cells.Rows.Count, "A").End(xlUp).Row + 1
Sheets("Sheet2").Range("A" & lastrow).PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks:=False, Transpose:=False

End If
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top