View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
davegb davegb is offline
external usenet poster
 
Posts: 573
Default Strange macro behavior!

Thanks, Dave!
The macro runs now, but is selecting data outside the table (other info
located further right in the spreadsheet. Is there a way to only select
the data in the table?



Dave Peterson wrote:
Oopsie. I left out a closing paren:

This:
.range("a1",.cells(lastrow,lastcol).name = "filterrange"
should be:
.range("a1",.cells(lastrow,lastcol)).name = "filterrange"

Sorry.

davegb wrote:

Thanks, Dave!
I've changed the order of the steps so it goes across the top

first,
which, as you said, has no blanks because of the column headers.

And
I've made sure that the right column has no blanks. Should take

care of
that problem.
I've discovered in discussion with the person feeding me the data

from
SPSS that this latest data, and some of the future data, comes from

an
entirely different database than what she had given before, and has
blanks and some serious formatting problems when downloaded into

Excel.
Blank cells, blank cells that aren't really blank, leading and

trailing
spaces, etc. Fortunately, I've gleaned some good programs here and
elsewhere to help with most of this.

As for your code, it won't run. First try, I got a compile error on
filterrange. I dimmed it as a range, and now I get a run error on

the
line:
.range("a1",.cells(lastrow,las*tcol).name = "filterrange"

I tried it with and without the quotes. I also turned it around,
because it seemed to me that filterrange should be defined as the

range
from a1 to lastrow, lastcol, not the other way around. Is there a

time
when you define variables backwards, like here?
I also tried changing it to xltoRight, then xlDown, because it

seemed
to me that from A1 I want to go to the right, then down to define

the
filterrange, not up and left. Is it just me, or does it seem like
everything in this code is backwards? What am I missing?
Any other ideas?


--

Dave Peterson