Hello friends,
I spent a while searching and googling a solution with no resolution.
Tried creating an array, but my array skills are lack luster.
Basically, I'd like a suggestion of an easier/cleaner block of code to accomplish the same thing. This code functions properly but seems very inefficient for my taste. I really only care about the top if block. There is other code in this sub, but didn't think it was important to include.
Dim DiagList as String
Dim HCC_WS as Worksheet
Dim CurRow as Long
If Me.tb_Diag1 <> "" And _
Me.tb_Diag2 <> "" And _
Me.tb_Diag3 <> "" And _
Me.tb_Diag4 <> "" Then
DiagList = Me.tb_Diag1 & Chr(10) & Me.tb_Diag2 & Chr(10) & Me.tb_Diag3 & Chr(10) & Me.tb_Diag4
ElseIf Me.tb_Diag1 <> "" And _
Me.tb_Diag2 <> "" And _
Me.tb_Diag3 <> "" And _
Me.tb_Diag4 = "" Then
DiagList = Me.tb_Diag1 & Chr(10) & Me.tb_Diag2 & Chr(10) & Me.tb_Diag3
ElseIf Me.tb_Diag1 <> "" And _
Me.tb_Diag2 <> "" And _
Me.tb_Diag3 = "" And _
Me.tb_Diag4 = "" Then
DiagList = Me.tb_Diag1 & Chr(10) & Me.tb_Diag2
ElseIf Me.tb_Diag1 <> "" And _
Me.tb_Diag2 = "" And _
Me.tb_Diag3 = "" And _
Me.tb_Diag4 = "" Then
DiagList = Me.tb_Diag1
Else
DiagList = ""
End If
If DiagList <> HCC_WS.Cells(CurRow, 7) Then
If HCC_WS.Cells(CurRow, 7) <> "" Then
Ans = MsgBox("A different Diagnosis already exists, would you like to overwrite the current Diagnosis?", vbYesNo)
Select Case Ans
Case vbYes
HCC_WS.Cells(CurRow, 7) = DiagList
Case vbNo
End Select
Else
HCC_WS.Cells(CurRow, 7) = DiagList
End If
End If
I spent a while searching and googling a solution with no resolution.
Tried creating an array, but my array skills are lack luster.
Basically, I'd like a suggestion of an easier/cleaner block of code to accomplish the same thing. This code functions properly but seems very inefficient for my taste. I really only care about the top if block. There is other code in this sub, but didn't think it was important to include.
Dim DiagList as String
Dim HCC_WS as Worksheet
Dim CurRow as Long
If Me.tb_Diag1 <> "" And _
Me.tb_Diag2 <> "" And _
Me.tb_Diag3 <> "" And _
Me.tb_Diag4 <> "" Then
DiagList = Me.tb_Diag1 & Chr(10) & Me.tb_Diag2 & Chr(10) & Me.tb_Diag3 & Chr(10) & Me.tb_Diag4
ElseIf Me.tb_Diag1 <> "" And _
Me.tb_Diag2 <> "" And _
Me.tb_Diag3 <> "" And _
Me.tb_Diag4 = "" Then
DiagList = Me.tb_Diag1 & Chr(10) & Me.tb_Diag2 & Chr(10) & Me.tb_Diag3
ElseIf Me.tb_Diag1 <> "" And _
Me.tb_Diag2 <> "" And _
Me.tb_Diag3 = "" And _
Me.tb_Diag4 = "" Then
DiagList = Me.tb_Diag1 & Chr(10) & Me.tb_Diag2
ElseIf Me.tb_Diag1 <> "" And _
Me.tb_Diag2 = "" And _
Me.tb_Diag3 = "" And _
Me.tb_Diag4 = "" Then
DiagList = Me.tb_Diag1
Else
DiagList = ""
End If
If DiagList <> HCC_WS.Cells(CurRow, 7) Then
If HCC_WS.Cells(CurRow, 7) <> "" Then
Ans = MsgBox("A different Diagnosis already exists, would you like to overwrite the current Diagnosis?", vbYesNo)
Select Case Ans
Case vbYes
HCC_WS.Cells(CurRow, 7) = DiagList
Case vbNo
End Select
Else
HCC_WS.Cells(CurRow, 7) = DiagList
End If
End If