On Thursday, November 26, 2015 at 5:03:00 PM UTC-8, GS wrote:
My bad! (aircode<g)
This..
lNextRow = .Cells(1, .Rows.Count).End(xlUp).Row + 1
..should be...
lNextRow = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
--
Garry
Hi Garry,
Thanks, actually if I had studied the code harder, I should have seen
that.
I did have to make a change on this line for the Resize columns.
.Cells(lNextRow, 1).Resize(UBound(vData), 4) = vData
Works great now.
Thanks for the array approach, I like the array shot at it, but it
still whacks me most often.
Howard
Why did you hardcode the cols? The code uses the cols in vData, which
is 4 based on your range of A:D! You should always let the code use the
array sizes for the data...
Ubound(vData), 2) = 4 since it specifies the 2nd dim (#cols)
...because the range it holds spans cols A:D. You likely forgot that
loading a worksheet range into a variant results a 2D array.
I don't even use hard values for the source range because the data
resides in a dynamic range named "InputData" on every sheet. I didn't
want to take you there with this thread in case it went over your head,
but I do this...
vData = wks.Range("InputData")
...so the code is 100% reusable as well as better self-documenting.
HTH
--
Garry
Free usenet access at
http://www.eternal-september.org
Classic
VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.
vb.general.discussion