lundi 28 août 2017

Values not being written to cells get popup though

Need help on below code which is not writing values to the cells but displays the msgbox

Sub SPD()
    Dim Col1, col2, col3, i, j, LRow, LCol As Long
    Dim st1, st2, st3 As String
    i = 0
    j = 0
    ThisWorkbook.Sheets.Add
    st1 = "Salus Hosting"
    LRow = Workbooks("Data").Sheets("Data").Cells(Rows.Count, 2).End(xlUp).Row

    For i = 2 To LRow
        If ThisWorkbook.Sheets("Data").Cells(i, 10).Value = "Salus Hosting" And ThisWorkbook.Sheets("Data").Cells(i, 30).Value = "EC2" Then
            MsgBox ThisWorkbook.Sheets("Data").Cells(i, 10).Value & ThisWorkbook.Sheets("Data").Cells(i, 30)
            ThisWorkbook.Sheets("Sheet1").Cells(i, 1).Value = ThisWorkbook.Sheets("Data").Cells(i, 10).Value
            ThisWorkbook.Sheets("Sheet1").Cells(i, 2).Value = ThisWorkbook.Sheets("Data").Cells(i, 17).Value
            ThisWorkbook.Sheets("Sheet1").Cells(i, 3).Value = ThisWorkbook.Sheets("Data").Cells(i, 20).Value
            ThisWorkbook.Sheets("Sheet1").Cells(i, 4).Value = ThisWorkbook.Sheets("Data").Cells(i, 21).Value
            ThisWorkbook.Sheets("Sheet1").Cells(i, 5).Value = ThisWorkbook.Sheets("Data").Cells(i, 29).Value
        End If
    Next i
End Sub

Aucun commentaire:

Enregistrer un commentaire