Hi there,
I'm new here so I hope I'm posting this correctly.
I have a little puzzle that I'm really struggling with.
Scenario
I have created a spreadsheet that holds my stock portfolio. I have a column in the main portfolio that I record if I have sold the stock.
What I want to do is move all my sold stocks to a seperate sheet where the value of the cell in that column = "YES"
I have googled and looked at 15 different examples and they are all so messy.
Below I created a Macro Recording and have added comments on what I am trying to do.
The issue is that my code is relevant to checking Range U6 only and determining if that is a "YES"
I would love it if I could somehow make this search for any row in column U and see which once area marked as "YES" and copy these into the SOLD worksheet.
The I would want to remove/delete these lines from the main worksheet once they have been copied/moved to the SOLD worksheet.
Sub Move_Rows()
' Check to See which Row in Column U has the word YES in it
' If this row has YES then select the entire row to copy
If Range("U6").Select = "YES" Then
Rows("6:6").Select
Selection.Copy
' Select Sheet named SOLD
' Determin first Empty Cell in Column B
Sheets("SOLD").Select
Range("B1000").Select
Selection.End(xlUp).Select
' Special Paste as Values
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
' Select Sheet named Portfolio
' Delete Row that was just copied into sheet SOLD
' Copy last empty row (as it has formulas) and Paste All by insterting new row
Sheets("Portfolio").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp
Range("C6").Select
Selection.End(xlDown).Select
Rows("13:13").Select
Selection.Copy
Selection.Insert Shift:=xlDown
End If
End Sub
Any help would be greatly appreciated, I suspect that this is a walk in the park for some expert VBA coders out there.
thanks in advance![]()
Bookmarks