I have data in Sheet1 and Sheet2 of the workbook.
I have the following code in which it copies the range values from Sheet2 based on a condition and has to paste the same range values at the end of Sheet1.
Somehow the code is not pasting the data on Sheet1 , any suggestions to debug will be of great help.
For c = 1 To maxCols
For R = 1 To maxRows
searchString = ""
On Error Resume Next
searchString = ws2.Cells(R, c).Value
Stat_val = ws2.Cells(R, 2).Value
If Stat_val = "SUBMITTED" Then
Set mycell = ws1.Cells.Find(What:=searchString, After:=ws1.Cells(2, 1), LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If mycell Is Nothing Then
With ws2.Range(Cells(R, c), Cells(R, 10))
.Copy ws1.Range(Cells(lr1 + 1, 1), Cells(lr1 + 1, 10))
ws1.Cells(lr1 + 1, 1).Resize(ws1.Rows.Count, _
ws1.Columns.Count).Value = .Value
ws1.Range(Cells(lr1 + 1, 1), Cells(lr1 + 1, 10)).PasteSpecial
End With
End If
Else
End If
Set mycell = Nothing
Next R
Next c
TIA
TKS
I have the following code in which it copies the range values from Sheet2 based on a condition and has to paste the same range values at the end of Sheet1.
Somehow the code is not pasting the data on Sheet1 , any suggestions to debug will be of great help.
For c = 1 To maxCols
For R = 1 To maxRows
searchString = ""
On Error Resume Next
searchString = ws2.Cells(R, c).Value
Stat_val = ws2.Cells(R, 2).Value
If Stat_val = "SUBMITTED" Then
Set mycell = ws1.Cells.Find(What:=searchString, After:=ws1.Cells(2, 1), LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If mycell Is Nothing Then
With ws2.Range(Cells(R, c), Cells(R, 10))
.Copy ws1.Range(Cells(lr1 + 1, 1), Cells(lr1 + 1, 10))
ws1.Cells(lr1 + 1, 1).Resize(ws1.Rows.Count, _
ws1.Columns.Count).Value = .Value
ws1.Range(Cells(lr1 + 1, 1), Cells(lr1 + 1, 10)).PasteSpecial
End With
End If
Else
End If
Set mycell = Nothing
Next R
Next c
TIA
TKS