View Single Post
  #5   Report Post  
BizMark BizMark is offline
Member
 
Location: London
Posts: 78
Default

Quote:
Originally Posted by Jenno
Thanks for your help with this, but when I try to run this I get a
syntax error. I am not familiar with Visual Basic, so not sure what
likely problems could be. Would it be possible for you to check my
coding - copied below

Sub CopyDataRow()
nInputRow = 2
nOutputRowStarts = 2

nRowsLogged =
Sheet2.Cells(nOutputRowStarts, 1).CurrentRegion.Rows.Count

For Each xCell In Sheet1.Rows(nInputRow).Cells
Sheet2.Cells(nRowsLogged + 1, xCell.Column) = xCell.Value
Next xCell




End Sub

Is that all coding or is any of it a comment, as I say not sure about
all the fine detail. Dim or what!

Jenno


--
Jenno
------------------------------------------------------------------------
Jenno's Profile: http://www.excelforum.com/member.php...o&userid=26236
View this thread: http://www.excelforum.com/showthread...hreadid=395283

Hmmm. I tried copying and pasting it into a module (I admit I just wrote it straight into the forum, I didn't test it) and it worked fine for me.
One thing though is that it assumed that the Headings were already in Row 2.
I tightened up the code to make sure this happens and also copies the cells in one hit, as follows:

Sub CopyDataRow()
nInputRow = 2
nOutputRowStarts = 2

If Range("Sheet2!A1").Text = "" Then
Sheet2.Rows(1).EntireRow.Cells.Value = _
Sheet1.Rows(1).EntireRow.Cells.Value
End If
nRowsLogged = Sheet2.Cells(1, 1).CurrentRegion.Rows.Count

Sheet2.Rows(nRowsLogged + 1).EntireRow.Cells.Value = _
Sheet1.Rows(nInputRow).Cells.Value
End Sub




Regards,
BizMark