endxlup failure because of table?

humboldtcountyguy

New Member
Joined
May 21, 2010
Messages
20
Can anyone tell me why the code below copies an entire table of blank rows instead of only those with data? And more importantly, how do i fix it? Thanks in advance guys :)

Code:
Sub ConsolidateCSV()

Dim sh As Worksheet, lr As Long, rng As Range
Dim si As Worksheet

Set sh = WorkSheets("Tables")
Set si = Worksheets("CSV")

lr = sh.Cells(Rows.Count, "A").End(xlUp).Row 'This finds the last row in the range
sh.Range("A2:E" & lr).Copy
Set pst = si.Range("a5535").End(xlUp).Offset(1, 0)
pst.PasteSpecial Paste:=xlPasteValues, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False

End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top