hi there I am just trying to adjust this code so that when it pastes the new info it starts on the 3rd row. Currently it starts on the 2nd row and erases information I need.... I have pretty much tried adjusting everything but cant do it.
Sub Fargos()
Dim wsScores As Worksheet
Dim wsFargos As Worksheet
Dim LastRow As Long 'last populated row column B, products sheet
Dim i As Long 'loop variable
Dim Counter As Long 'row counter for PO sheet
Set wsScores = Sheets("Scores")
Set wsFargos = Sheets("Fargos")
With wsFargos
Range("A3:C100").Select
Selection.ClearContents
End With
'find last populated row, column A, Scoresheet
With wsScores
LastRow = .Range("A" & .Rows.Count).End(xlUp).Row
End With
Counter = 1 'row counter Main sheet
'loop through products sheet
For i = 1 To LastRow 'assuming header row
'check if column B is empty
If wsScores.Range("A" & i).Value <> "" Then
Counter = Counter + 2
wsFargos.Range("A" & Counter).Value = wsScores.Range("A" & i).Value
wsFargos.Range("B" & Counter).Value = wsScores.Range("B" & i).Value
wsFargos.Range("C" & Counter).Value = wsScores.Range("C" & i).Value
wsFargos.Range("D" & Counter).Value = wsScores.Range("D" & i).Value
End If
Next i
Range("A3:D100").Select
ActiveWorkbook.Worksheets("Fargos").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Fargos").Sort.SortFields.Add Key:=Range("A3:A100") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Fargos").Sort.SortFields.Add Key:=Range("C3:C100") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Fargos").Sort
.SetRange Range("A3:D100")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Sub Fargos()
Dim wsScores As Worksheet
Dim wsFargos As Worksheet
Dim LastRow As Long 'last populated row column B, products sheet
Dim i As Long 'loop variable
Dim Counter As Long 'row counter for PO sheet
Set wsScores = Sheets("Scores")
Set wsFargos = Sheets("Fargos")
With wsFargos
Range("A3:C100").Select
Selection.ClearContents
End With
'find last populated row, column A, Scoresheet
With wsScores
LastRow = .Range("A" & .Rows.Count).End(xlUp).Row
End With
Counter = 1 'row counter Main sheet
'loop through products sheet
For i = 1 To LastRow 'assuming header row
'check if column B is empty
If wsScores.Range("A" & i).Value <> "" Then
Counter = Counter + 2
wsFargos.Range("A" & Counter).Value = wsScores.Range("A" & i).Value
wsFargos.Range("B" & Counter).Value = wsScores.Range("B" & i).Value
wsFargos.Range("C" & Counter).Value = wsScores.Range("C" & i).Value
wsFargos.Range("D" & Counter).Value = wsScores.Range("D" & i).Value
End If
Next i
Range("A3:D100").Select
ActiveWorkbook.Worksheets("Fargos").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Fargos").Sort.SortFields.Add Key:=Range("A3:A100") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Fargos").Sort.SortFields.Add Key:=Range("C3:C100") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Fargos").Sort
.SetRange Range("A3:D100")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub