Created command button running the macro below. I need help with two things:
1 - How do compare to cells in column 2 until the end of list - which is blank
2 - how and where to I insert a message box if no matches to the value in F91 is found after going thru the FOR loop - 'MsgBox "Please check AppID and try uploading again"
Private Sub CommandButton1_Click()
Dim wksFrom As Worksheet
Dim wksTo As Worksheet
Dim wksFrom2 As Worksheet
Dim wkbfrom As Workbook
Dim wkbto As Workbook
Dim irow As Long
Set wkbfrom = Workbooks("VBA testing.xlsm")
Set wkbto = Workbooks("Import test.xlsx")
Set wksFrom = wkbfrom.Worksheets("Sheet1") ' or perhaps "Sheeet1" no space
Set wksFrom2 = wkbfrom.Worksheets("Sheet2")
Set wksTo = wkbto.Worksheets("2012 Schedule")
With wksFrom
For irow = 1 To 100
'Do Until IsEmpty(Cells(irow, 2))
If wksFrom.Range("F91") = wksTo.Cells(irow, 2) Then
wksTo.Cells(irow, 16).Value = wksFrom2.Range("B3")
wksTo.Cells(irow, 17).Value = wksFrom2.Range("B4")
wksTo.Cells(irow, 18).Value = wksFrom2.Range("B5")
wksTo.Cells(irow, 19).Value = wksFrom2.Range("B6")
wksTo.Cells(irow, 21).Value = wksFrom2.Range("B7")
Exit For
'Else
'MsgBox "Please check AppID and try uploading again"
End If
'irow = irow + 1
'Loop
Next irow
End With
MsgBox "Update Sent"
wksFrom2.Range("B10").Value = Date
End Sub
Bookmarks