bryanrobson
New Member
- Joined
- Aug 19, 2022
- Messages
- 21
- Office Version
- 365
- Platform
- Windows
Hi. I have the code below. I have selected data in cells A, B, C, F, G and H. UI have copied that row and I want to paste that into another worksheet ws2 / Combined for Lookup into the next row available after the last row.
I dont want to use some form of a loop. Is there a one liner of code I can do that with as I dont want to use a loop to just copy one line and paste straight away into another sheet.
Many thanks
Set WsF = Application.WorksheetFunction
Set ws1 = ThisWorkbook.Sheets("events log")
Set ws2 = ThisWorkbook.Sheets("Combined for Lookup")
For Rw = 2 To 9999
On Error Resume Next
ws1.Cells(Rw, "I") = WsF.VLookup(ws1.Cells(Rw, "B"), ws2.Range("B2:G9999"), 6, False)
If ws1.Cells(Rw, "I") = "n/a" Or _
ws1.Cells(Rw, "I") = "" Then
ws1.Cells(Rw, 1).EntireRow.Font.Bold = True
ws1.Cells(Rw, 1).EntireRow.Font.Color = Black
shtName = "A" & Rw & "," & "B" & Rw & "," & "C" & Rw & "," & "F" & Rw & "," & "G" & Rw & "," & "H" & Rw
Range(shtName).Select
Selection.Copy
End If
Next Rw
I dont want to use some form of a loop. Is there a one liner of code I can do that with as I dont want to use a loop to just copy one line and paste straight away into another sheet.
Many thanks
Set WsF = Application.WorksheetFunction
Set ws1 = ThisWorkbook.Sheets("events log")
Set ws2 = ThisWorkbook.Sheets("Combined for Lookup")
For Rw = 2 To 9999
On Error Resume Next
ws1.Cells(Rw, "I") = WsF.VLookup(ws1.Cells(Rw, "B"), ws2.Range("B2:G9999"), 6, False)
If ws1.Cells(Rw, "I") = "n/a" Or _
ws1.Cells(Rw, "I") = "" Then
ws1.Cells(Rw, 1).EntireRow.Font.Bold = True
ws1.Cells(Rw, 1).EntireRow.Font.Color = Black
shtName = "A" & Rw & "," & "B" & Rw & "," & "C" & Rw & "," & "F" & Rw & "," & "G" & Rw & "," & "H" & Rw
Range(shtName).Select
Selection.Copy
End If
Next Rw