I have a userform that has the same type information on 3 different entities (name, address, phone, etc). The same research is required on each one i.e. you need to look up the zip code for each). Therefore I have a bank of buttons on each page of the multipage form. Each button does the same thing depending on which page you are on. The following is my code to copy some information and open another application depending on which page you are on and which type entity.
My question is how can I combine these into one so my module is not 3' long.
Private Sub SUMRYButton1_Click() If Sheets("Info").Range("B197") = "BMF" Then Sheets("Info").Range("B208").Copy Else End If If Sheets("Info").Range("B197") = "IMF" Then Sheets("Info").Range("B223").Copy Else End If On Error GoTo EH ActivateWindow "attachmate" Exit Sub EH: MsgBox "IDRS is not open" End Sub Private Sub SUMRYButton2_Click() If Sheets("Info").Range("C197") = "BMF" Then Sheets("Info").Range("C208").Copy Else End If If Sheets("Info").Range("C197") = "IMF" Then Sheets("Info").Range("C223").Copy Else End If On Error GoTo EH ActivateWindow "attachmate" Exit Sub EH: MsgBox "IDRS is not open" End Sub Private Sub SUMRYButton3_Click() If Sheets("Info").Range("D197") = "BMF" Then Sheets("Info").Range("D208").Copy Else End If If Sheets("Info").Range("D197") = "IMF" Then Sheets("Info").Range("D223").Copy Else End If On Error GoTo EH ActivateWindow "attachmate" Exit Sub EH: MsgBox "IDRS is not open" End Sub
Bookmarks