Click here to Skip to main content
15,943,419 members

Comments by BASSIES (Top 21 by date)

BASSIES 24-Jan-24 10:34am View    
Thanks for the reply , i give it a try on different windows machine.
BASSIES 3-Aug-23 5:31am View    
Thanks !
BASSIES 5-Feb-19 15:00pm View    
Is there a better way , and not from a database.
BASSIES 5-Feb-19 14:58pm View    
This is working , find last row but it is slow

Private Sub copyAlltoClipboard()
DataGridView1.SelectAll()
Dim dataObj As DataObject = DataGridView1.GetClipboardContent()
If dataObj IsNot Nothing Then Clipboard.SetDataObject(dataObj)
End Sub
Private Sub copyAlltoClipboard2()
DataGridView2.SelectAll()
Dim dataObj As DataObject = DataGridView2.GetClipboardContent()
If dataObj IsNot Nothing Then Clipboard.SetDataObject(dataObj)
End Sub

Private Sub Crew2()
copyAlltoClipboard()
Dim xlexcel As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
xlexcel = New Excel.Application
xlexcel.Visible = True
xlWorkBook = xlexcel.Workbooks.Open("C:\weg\Verbruik.xlsx")
xlWorkSheet = xlWorkBook.Worksheets(1)

Dim CR As Excel.Range = xlWorkSheet.Cells(37, 1)
CR.PasteSpecial()


Dim lastRow As Integer = xlWorkSheet.UsedRange.Rows.Count

Dim emptyRow As Integer = lastRow + 3

lastRow = xlWorkSheet.UsedRange.Rows.Count
'This is next emptyRow in the sheet
emptyRow = lastRow + 3
copyAlltoClipboard2()

Dim CR1 As Excel.Range = xlWorkSheet.Cells(emptyRow, 1)
CR1.PasteSpecial()


xlWorkBook.SaveAs("C:\weg\Verbruik1.xlsx")
xlWorkBook.Close()
End Sub
BASSIES 22-Jan-19 10:26am View    
Thanks Bryian ,

I can remove it if wanted.