vendredi 3 septembre 2021

VBA - Adding a name inside the IF

Good Morning, I'm having some issue regarding the below code:

Sub Sendorders()

Application.ScreenUpdating = False

Dim wb As Workbook: Set wb = Workbooks("Hugo Automate V15.xlsm")
Dim ws As Worksheet: Set ws = wb.Worksheets("Bid-Ask")

Dim i As Long

ws.Activate

ws.Cells(2, 20) = ws.Cells(2, 20) & " Equity"

For i = 8 To 242
 If ws.Cells(2, 20).Value = ws.Cells(i, 1).Value Then

 If Cells(2, 23) = "BUY" Then
    Cells(i, 20) = Cells(2, 22)
    Cells(i, 21) = Cells(2, 21)
 Else
    Cells(i, 22) = Cells(2, 22)
    Cells(i, 23) = Cells(2, 21)
 End If
 End If
Next

Application.ScreenUpdating = True

End Sub

I would like to compile the ligne 7 with the ligne 10 like this:

If ws.Cells(2,20) & "Equity".Value = ws.Cells(i,1).Value Then

However this doesn't work...

Thanks a lot for your help & time,

Regards,

Aucun commentaire:

Enregistrer un commentaire