Guys I need your help again
I use this code to copy values from excel spreadsheet to datagrid.
Try
's = Clipboard.GetText()
Dim tArr() As String
Dim arT() As String
Dim i, ii As Integer
Dim c, cc, r As Integer
tArr = Clipboard.GetText().Split(Environment.NewLine)
r = Form1.DataGridView1.SelectedCells(0).RowIndex
c = Form1.DataGridView1.SelectedCells(0).ColumnIndex
For i = 0 To tArr.Length - 1
If tArr(i) <> "" Then
arT = tArr(i).Split(vbTab)
cc = c
For ii = 0 To arT.Length - 2
If cc > Form1.DataGridView1.ColumnCount - 1 Then Exit For
If r > Form1.DataGridView1.Rows.Count - 1 Then Exit Sub
With Form1.DataGridView1.Item(cc, r)
.Value = arT(ii).TrimStart
End With
cc = cc + 1
Next
r = r + 1
End If
Next
Catch ex As Exception
MsgBox("Please redo Copy and Click on cell")
End Try
It works fine but is it possible for some certain cells in datagrid not to be pasted with value? Example:
In datagrid Columns A, B, C, D, E are shown while in excel spreadsheet there are columns A, B, D, E.
If I copy the values from excel the value of columns D and E will be pasted in columns C and D in datagrid?