Hi Guys,


I have this code,

Private Sub CommandButton1_Click()

Dim bk As Workbook
Dim bSave As Boolean
Dim lRow As Long

' test to see if .xls already open

On Error Resume Next
Set bk = Workbooks("RFM.xlsx")
On Error GoTo 0
If bk Is Nothing Then
bSave = True
Set bk = Workbooks.Open("C:\RFM\RFM.xlsx")
End If

'find first empty row in database
lRow = bk.Worksheets("TnT").Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
ThisWorkbook.Sheets("TICKET_LOAD_EXTRACT_2_SCRIPT").Range("A4:X23").Copy
bk.Worksheets("TnT").Cells(lRow, 1).PasteSpecial Paste:=xlPasteValues

' if destination was originally closed, then save and close it

If bSave Then bk.Close Savechanges:=True
End Sub
There is a formula in each of the "A4:A23" cells;
=MID(Acc,1,8)
, but, when there is no value into Acc, the cell is left blank. And, as I'm doing "PasteSpecial Paste:=xlPasteValues" I can't figure this out. Why is my code pasting the blank cells? As the range (A4:X23) isn't always full, I ONLY want to copy those non-blank cells.
When I delete the formula from A4:A23 then, it does what I want, It does not copy the blanks.

So, I don't know... visually speaking, it's blank but, there is a formula assigned to the cell thus, it does not do what I want it to do.

I hope you guys can figure this out. if you need more details, just let me know.

Thanks in advance