Interrupting an add line

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using the following code to add data to the next open line on a spreadsheet

Sub AddData(

' Macro recorded 12/8/2003 by Brian McGuir

Sheets("input").Range("A20:AB20").Copy Destination:=
Sheets("database").Cells(Rows.Count, 1).End(xlUp)
.Offset(1, 0
Worksheets("input").Range("A20:AB20").ClearContent

End Su

This works fine, but I now need to skip columns N, O, and P when adding this data. These are calculated via a formula using data from other rows, and I need to keep this formula in the destination cell for the sake of future editing of data in the actual spreadsheet. How can I still add all the columns to the next open row, but skip the three I have mentioned. Thanks in advance

Brian
 
Brian,

Use two lines to do the copy/paste:

Sheets("input").Range("A20:M20").Copy Destination:= _
Sheets("database").Cells(Rows.Count, 1).End(xlUp) _
.Offset(1, 0)
Sheets("input").Range("Q20:AB20").Copy Destination:= _
Sheets("database").Cells(Rows.Count,
Range("Q1").Column).End(xlUp) _
.Offset(1, 0)

HTH,
Bernie
MS Excel MVP

Brian McGuire said:
I am using the following code to add data to the next open line on a spreadsheet:

Sub AddData()

' Macro recorded 12/8/2003 by Brian McGuire

Sheets("input").Range("A20:AB20").Copy Destination:= _
Sheets("database").Cells(Rows.Count, 1).End(xlUp) _
.Offset(1, 0)
Worksheets("input").Range("A20:AB20").ClearContents

End Sub

This works fine, but I now need to skip columns N, O, and P when
adding this data. These are calculated via a formula using data from
other rows, and I need to keep this formula in the destination cell
for the sake of future editing of data in the actual spreadsheet. How
can I still add all the columns to the next open row, but skip the
three I have mentioned. Thanks in advance.
 
Back
Top