Strugglestreet
New Member
Hello everyone,
I am very new to VBA and am trying to create a piece of code (Button is in ASX workbook) that compares each row of data in column A of worksheet ASX300 with the data in worksheet Consumer Discretionary and if not found copy the entire row and display a text box highlighting new data has arrived. I've created the below code but i believe it needs the variables for the range and i haven't a clue what to do with it. If some can please help me that would be greatly appreciated! I have attached the spreadsheet as well.
I am very new to VBA and am trying to create a piece of code (Button is in ASX workbook) that compares each row of data in column A of worksheet ASX300 with the data in worksheet Consumer Discretionary and if not found copy the entire row and display a text box highlighting new data has arrived. I've created the below code but i believe it needs the variables for the range and i haven't a clue what to do with it. If some can please help me that would be greatly appreciated! I have attached the spreadsheet as well.
Code:
Private Sub CommandButton1_Click()
With Sheets("ASX300").Range("A:A")
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
Else
Worksheets("Consumer discretionary").Activate
b = Worksheets("Consumer Discretionary").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Consumer Discretionary").Cells(b + 1, 1).Select
ActiveSheet.Paste
MsgBox (New_Consumer_Discretionary_Item)
End If
End With
Application.CutCopyMode = False
ThisWorkbook.Worksheets("ASX300").Cells(1, 1).Select
End Sub