Hi guys,
I have written this code that draws data from one sheet to another (Please see the code below). I use a do until loop to do this. But I have 2 problems with it.
1. I have a formula commanding to return "" in case of an error in the original data and I don't want the code to draw the empty data (meaning the ones with ""). Hence "End(xlUp).Row" is not cutting it for me. How can I achieve this?
2. In the code, the copy and paste selection ranges are supposed to go to the end but it just copies the first row of the selected columns and that's it.
It's crucial for me to stop copying if the cell is "" and not absolute blank because I will use the copied data to create a pivot table. If the data with "" formula is there, it will pick it up as data and include it in the table, ruining my slicers.
Thank you very much in advance!
Sub GetData()
Dim Lastrow As Integer
Lastrow = Worksheets("Clean Data_I").Cells(Rows.Count, 1).End(xlUp).Row
Dim Counter As Integer
Counter = 1
Do Until Counter = Lastrow + 1
'Worksheets("Clean Data_I").Range("U" & Counter & ":Y" & Counter).Copy
Worksheets("Clean Data_I").Range("U1:Y500").Copy
Dim LastRowDest As Integer
LastRowDest = Worksheets("Clean Data_I2").Cells(Rows.Count, 1).End(xlUp).Row
'Worksheets("Clean Data_I").Range("A" & Counter & ":E" & Counter).PasteSpecial xlPasteValues
Worksheets("Clean Data_I2").Range("A1:E500").PasteSpecial xlPasteValues
Counter = Counter + 1
Loop
Worksheets("Clean Data_I2").Columns.AutoFit
End Sub
Bookmarks