Hi
I search for way to skip blank cells for range in this line
ar = .Sheets(5).Range("g2:i1000").Value
somtimes I have few data in range G2:I100 the others cells will be blank . so I search for way to skip blank cells by just import data are filled in cells with ignore empty cells . I try two ways:
1- add condition
If ar <> "" Then
2- change range to
ar=sheets(5).Range("G2:I" & Cells(Rows.Count, "G").End(xlUp).Row)
two both ways don't work and shows errors.
Sub ge_tdata()
Dim ar As Variant, lRw As Long
' get last row number in column B
lRw = ThisWorkbook.Sheets("sheet1").Cells(Rows.Count, 2).End(xlUp).Row
With Application.FileDialog(msoFileDialogFilePicker)
If .Show Then
With GetObject(.SelectedItems(1))
ar = .Sheets(5).Range("g2:i1000").Value
If ar <> "" Then
' copy to bottom of row B
ThisWorkbook.Sheets("sheet1").Cells(lRw + 1, 2).Resize(UBound(ar), UBound(ar, 2)) = ar
.Close 0
End If
End With
End If
End With
End Sub
I hope to find idea to fix this problem .