correction needed

  • Thread starter Thread starter K
  • Start date Start date
K

K

I been sent macro by one of online friend . This macro copies entire
row from sheet1 to sheet2. what should i do that this macro only copy
rows from cell A to cell F instead of coping entire row. please any
body can give any suggestions or macro

Sub movedata()

OldShRowCount = 1
NewShRowCount = 2

With Sheets("Sheet1")
Do While .Range("D" & OldShRowCount) <> ""
If (.Range("D" & OldShRowCount) = .Range("D" & (OldShRowCount + 1)))
And (.Range("E" & OldShRowCount) <> .Range("E" & (OldShRowCount + 1)))
Then
..Rows(OldShRowCount).Copy
Destination:=Sheets("Sheet2").Rows(NewShRowCount)
NewShRowCount = NewShRowCount + 1
End If
OldShRowCount = OldShRowCount + 1
Loop
End With


End Sub
 
Start over and tell us exactly what you want to do with before/after
examples. It probably can be that you copy all at once instead of one at a
time.
but to answer your question about copy range
to
..range(cells(OldShRowCount,"a"),cells(OldShRowCount,"f")).Copy _
Sheets("Sheet2").range(NewShRowCount,"a")
 
Start over and tell us exactly what you want to do with before/after
examples. It probably can be that you copy all at once instead of one at a
time.
but to answer your question about copy range


to
.range(cells(OldShRowCount,"a"),cells(OldShRowCount,"f")).Copy _
Sheets("Sheet2").range(NewShRowCount,"a")

--
Don Guillett
Microsoft MVP Excel
SalesAid Software









- Show quoted text -

Thanks Don this really works
 
Most of us TOP post here. I guess that your statement means that my
suggestion helped and that you don't want to know a better way?
 
Don, I think K has a secret project going on. The OP does not give very much
info about what they are trying to do, just what they want the macro to do,
one piece at the time.
 

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

Back
Top