A
ajm1949
I have been using the following code to add items from one worksheet to
another in a specific row and column. I have used this code for a few years.
Recently when editing in Excel 2007 (compatability mode) the counter stops
working. ie it always puts the data in row 7 instead of counting down one row
for each additional item.Does any one have any ideas on what has changed or
is there a better way to control where the copied data is placed.
Sub FordRetail()
'<<RETAIL
On Error Resume Next
Dim WkSht As Worksheet
Dim Counter As Long
Dim RowCount As Long
Dim i As Object, Y As Object
Set WkSht = Sheets("Calculator")
r$ = Trim(Str(ActiveCell.Row))
Counter = 7
Do While Not Range("Ford2007.xls!A" & Counter).Value = ""
Counter = Counter + 1
Loop
'<< <your code to initialize counter>
For Each i In Selection.Areas
RowCount = RowCount + i.Rows.Count
Next i
'<<If Counter <=18Then '<< Maybe S/B Counter
If RowCount <= 26 Then '<<??????
For Each Y In Selection
WkSht.Cells(Counter, 1).Value = Cells(Y.Row, 2).Value
'<<Cells(Row,Column) B;A Vehicle
WkSht.Cells(Counter, 4).Value = Cells(Y.Row, 1).Value '<<Code
WkSht.Cells(Counter, 2).Value = _
Cells(Y.Row, 3).Value + Cells(Y.Row, 4).Value + Cells(Y.Row,
5).Value '<<RRP No LCT
WkSht.Cells(Counter, 12).Value = _
Cells(Y.Row, 3).Value + Cells(Y.Row, 4).Value + Cells(Y.Row,
5).Value '<<RRP No LCT
WkSht.Cells(Counter, 7).Value = Cells(Y.Row, 5).Value '<<MARGIN
Counter = Counter + 1
Next Y
Else
MsgBox "Too Many Items", vbExclamation, "Quotemaster"
End If
End Sub
Cheers
Alan
another in a specific row and column. I have used this code for a few years.
Recently when editing in Excel 2007 (compatability mode) the counter stops
working. ie it always puts the data in row 7 instead of counting down one row
for each additional item.Does any one have any ideas on what has changed or
is there a better way to control where the copied data is placed.
Sub FordRetail()
'<<RETAIL
On Error Resume Next
Dim WkSht As Worksheet
Dim Counter As Long
Dim RowCount As Long
Dim i As Object, Y As Object
Set WkSht = Sheets("Calculator")
r$ = Trim(Str(ActiveCell.Row))
Counter = 7
Do While Not Range("Ford2007.xls!A" & Counter).Value = ""
Counter = Counter + 1
Loop
'<< <your code to initialize counter>
For Each i In Selection.Areas
RowCount = RowCount + i.Rows.Count
Next i
'<<If Counter <=18Then '<< Maybe S/B Counter
If RowCount <= 26 Then '<<??????
For Each Y In Selection
WkSht.Cells(Counter, 1).Value = Cells(Y.Row, 2).Value
'<<Cells(Row,Column) B;A Vehicle
WkSht.Cells(Counter, 4).Value = Cells(Y.Row, 1).Value '<<Code
WkSht.Cells(Counter, 2).Value = _
Cells(Y.Row, 3).Value + Cells(Y.Row, 4).Value + Cells(Y.Row,
5).Value '<<RRP No LCT
WkSht.Cells(Counter, 12).Value = _
Cells(Y.Row, 3).Value + Cells(Y.Row, 4).Value + Cells(Y.Row,
5).Value '<<RRP No LCT
WkSht.Cells(Counter, 7).Value = Cells(Y.Row, 5).Value '<<MARGIN
Counter = Counter + 1
Next Y
Else
MsgBox "Too Many Items", vbExclamation, "Quotemaster"
End If
End Sub
Cheers
Alan