I've managed to get it working, partially - now it's just a matter of getting these two functions working under one button.
Private Sub PasteData()
Worksheets("Results").Range("A2:Z900").Clear
Worksheets("Data").Range("D2:D220").SpecialCells(xlCellTypeVisible).Copy _
Destination:=Worksheets("Results").Range("A2")
Dim dbresults As Range
Set dbresults = Worksheets("Results").Range("A1:A200")
Set dbresults = dbresults.Rows("2:" & dbresults.Rows.Count)
Dim r As Range
For Each r In dbresults.Rows
If r.Cells(, EMAIL_COL) = "" _
Then
ElseIf r.Cells(2, EMAIL_COL) = "" _
Then
Else
r.Cells(, EMAIL_COL) = r.Cells(, EMAIL_COL) & "; "
End If
Next r
End
End Sub
Private Sub CopyEmail()
Dim myvalue As String
Dim x As Long
myvalue = ""
For x = 4 To 7
myvalue = myvalue & Worksheets("Results").Cells(x, "A")
Next x
Worksheets("Results").Cells(102, "A").Value = myvalue
Dim DataObj As New MSForms.DataObject
Dim S As String
S = myvalue
DataObj.SetText S
DataObj.PutInClipboard
End Sub
Private Sub Commandbutton1_Click()
CopyEmail
PasteData
End Sub
Is my sub PasteData() not "ending" correctly? Because if I assign these two subs to two different buttons, then it works 100%. But if I assign both subs to one button, or both functions under one sub - it fails.
Bookmarks