I did that several times manualy and the same problem. I even deleted all the columns after column D
the data is populated by worksheet change event (may be something wrong in the code)
Code: Select all
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim ws As Worksheet, sh As Worksheet, lr As Long, iRow As Long, m As Long
If Target.Cells.CountLarge > 1 Then Exit Sub
If Target.Address = "$A$1" Then
Cancel = True
Application.ScreenUpdating = False
Set ws = shClients: Set sh = shCSV
sh.Range("A1").CurrentRegion.Offset(1).ClearContents
With ws
lr = .Cells(Rows.Count, 1).End(xlUp).Row
m = 2
For iRow = 2 To lr
If .Cells(iRow, "E").Value <> Empty And .Cells(iRow, "F").Value <> Empty Then
sh.Cells(m, "A").Value = .Cells(iRow, "E").Value
sh.Cells(m, "B").Value = .Cells(iRow, "B").Value
sh.Cells(m, "C").Value = .Cells(iRow, "F").Value
sh.Cells(m, "D").Value = "-"
m = m + 1
End If
If .Cells(iRow, "G").Value <> Empty And .Cells(iRow, "H").Value <> Empty Then
sh.Cells(m, "A").Value = .Cells(iRow, "G").Value
sh.Cells(m, "B").Value = .Cells(iRow, "B").Value
sh.Cells(m, "C").Value = .Cells(iRow, "H").Value
sh.Cells(m, "D").Value = "-"
m = m + 1
End If
Next iRow
End With
Application.ScreenUpdating = True
End If
End Sub