I\'m new to programming in VBA and I\'m looking To take data from different worksheets that matches a condition. Then copy and paste from one specific cell to another specific
I was working through the duplicate question for this and provided this answer:
Try:
Sub CopyValues()
'Declare counter variables
Dim i As Integer, j as Integer, lastrow As Long
'Declare variables
Dim Sourcedataws As Worksheet, WStotransfer As Worksheet
'Declare sheet variables
Set Sourcedataws = ThisWorkbook.Sheets("Source Data")
Set WStotransferws = ThisWorkbook.Sheets("WStotransfer")
lastrow = Sourcedataws.Cells(Sourcedataws.Rows.Count, "A").End(xlUp).Row
WStotransferws.Range("C18:I18").ClearContents
For i = 2 To lastrow
If WStotransferws.Range("I18").Value="" Then
If Sourcedataws.Range("AA" & i).Value = "Condition" Then
Sourcedataws.Range("A"&i).Copy
j=WStotransferws.Cells(18, WStotransferws.Columns.Count).End(xlToLeft).Column
WStotransferws.Cells(18,j+1).PasteSpecial xlPasteValues
End If
Else
End If
Next i
End Sub
Other post found: VBA Need a Nested Loop to shift columns
There's a long conversation with the poster about details that were not in the post.